How to order a table with multiple field? I tried ...
# help
j
How to order a table with multiple field? I tried to add multiple order(), but that doesn't seem to work
n
Hello @joshcowan25! 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.
b
What happens when you call
order()
twice? Can you post the sample code?
n
joshcowan25 (2022-06-06)
j
I receive a 400. order[0] = {field: "col1", asc: false}
b
Here's an example someone gave me that works:
Copy code
supabase
.from("parents")
.select("*, children(*)")
.order('name', { ascending: false})
.order('name', { foreignTable: 'children', ascending: false})
Your syntax looks a little wonky to me.
Can you try simplifying it or hard-coding some values to test it first?
j
It's because it is dynamic. But your example made me realize that I think I don't include all the columns I need in the select...
b
I'm not sure what's happening with your
foreignTable}:
part there.
j
Ohhh! That part is just an helper from Webstorm IDE. {ascending, nullsFirst, ForeigneTable}: is not in the code, it just show what property are available
b
oh, ok... do you have just the raw code?
or have you figured it out already 🙂 ?
j
Yeah! My code was working, but I had a typo in the config file containing columns name 😮 Thank you!
n
Thread was archived by @joshcowan25. Anyone can send a message to unarchive it.