Hello 🙂 I was wondering if someone could help me ...
# help
c
Hello 🙂 I was wondering if someone could help me convert this into Supabase's JavaScript SDK format?
Copy code
sql
SELECT 
  *,
  ROW_NUMBER () OVER (ORDER BY timestamp DESC)
...
n
Hello @CodeCo! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
g
If you must have the row number in each returned record without processing the returned array records then you would have to use an rpc call to a postgres function. Otherwise I would just do your select with .order(timestamp,{ascending:false}) added. Then you know the row number by the index number so you can either just process the data array in a loop using index as you need, or if you must have it in the actual object then do:
Copy code
data.forEach(function(row, index) {
  row.row_number = index;  //or index+1 to start at 1
});
or any other javascript method to do that.
n
CodeCo (2022-05-06)