select json attributes
See original GitHub issueconst existedIds = (await AEntity.findAll({
attributes: [ [sequelize.json("aStruct.id"), "aStruct.id"]],
where: { aStruct: { someKey: "someValue" } },
logging: console.log
})).map(model => model.get("aStruct.id"))
will lead to
SequelizeDatabaseError: column "astruct" does not exist
the SQL sentence:
Executing (default): SELECT aStruct#>>'{id}' FROM "aEntity" AS "aEntity" WHERE (("aEntity"."aStruct"#>>'{someKey}') = 'someValue');
SELECT aStruct#>>'{id}'
should be SELECT "aStruct"#>>'{id}'
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:16 (14 by maintainers)
Top Results From Across the Web
Retrieve attributes from JSON message
Specify the list of attributes for the API Gateway to retrieve using appropriate JSON Path expressions. All attribute values are stored in the...
Read more >How to select some properties in JSON - Stack Overflow
Use Array.prototype.map to iterate through your array, then for each object construct a new object with just the properties that interest ...
Read more >Work with JSON data - SQL Server - Microsoft Learn
The optional strict prefix in the path specifies that values for the specified properties must exist in the JSON text. For more information,...
Read more >12.18.3 Functions That Search JSON Values
The functions in this section perform search or comparison operations on JSON values to extract data from them, report whether data exists at...
Read more >How to Query a JSON Object in SQL Server - PopSQL
Here's how you can query a JSON column in SQL Server. Get only home_address.state from the employees table: select json_value(home_address,'$.state') as ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You should give it an alias
attributes: [ [sequelize.json("aStruct.id"), 'id']]
Hmm, we do have some tests for this, seems to work https://github.com/sequelize/sequelize/blob/9f0b5d1af24f6741aadebba411a21dc1d774d2c1/test/integration/dialects/postgres/dao.test.js#L170