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.

Order by json field

See original GitHub issue

Is there a way to order by a postgres json field?

Post.findAll({
  order: "json_document->>'json_field' ASC"
})

Or something similar. It seems that this is sanitized to the degree that it is not possible, but I could be missing something here.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
calvintwrcommented, Nov 10, 2015

@janmeier haha i saw that coming. okay i will do it when i’m free.

0reactions
shimecommented, Nov 20, 2017

Never mind. Fixed by using sequelize.literal instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

order by JSON data type postgres - Stack Overflow
I want to query the table records and order the results by a value stored in the JSON field. I'm getting the queries...
Read more >
JSON Sorter - Sort JSON keys and values online - CodeShack
The purpose of the JSON Sorter tool is to sort key names and key values, this can be both alphabetical and numerical values,...
Read more >
Clever way to order a json item by key in postgresql (two ...
jsonitem ) ORDER BY (value->>'key')::int -- true integer sort! ) sub ) arr;. It really depends on where your values come from, what...
Read more >
How to Sort MySQL JSON Data Correctly - @jianjye
If you are doing any type of ordering with MySQL JSON especially ... sorting are based on the numeric values of the bytes...
Read more >
Sorting JSON structures by multiple fields in JavaScript
If we would like to sort the list only by the word field, here's the simple trick: Array.sort() can take a function 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