Open iostreamdoth opened 7 years ago
How do I sort rows on the basis of a key in a jsonb type. My jsonb data looks like this, column name is RESULTS.
{"data":"a","count":"10"} {"data":"b","count":"11"} {"data":"c","count":"13"} {"data":"d","count":"3"}
I want to use it like .sortBy(row =>row.results.data.asc)
I tried a query to do this in Postgres
select * from public."OPERATION" ORDER BY "RESULTS"->>'data' ASC
and slick class has def results = column[Option[JsValue]]("RESULTS")
def results = column[Option[JsValue]]("RESULTS")
can we achieve this somehow through slick?
Hi @nishantsharmajecrc you can try [theTableQuery].sortBy(_.results..+>>("data")). I just tried it here, it should be OK.
[theTableQuery].sortBy(_.results..+>>("data"))
thanks @tminglei . That worked.
How do I sort rows on the basis of a key in a jsonb type. My jsonb data looks like this, column name is RESULTS.
I want to use it like .sortBy(row =>row.results.data.asc)
I tried a query to do this in Postgres
and slick class has
def results = column[Option[JsValue]]("RESULTS")
can we achieve this somehow through slick?