question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

select json attributes

See original GitHub issue
const 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
janmeiercommented, Aug 10, 2016

You should give it an alias attributes: [ [sequelize.json("aStruct.id"), 'id']]

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found