0

I have a supabase table with a column of boolean type, whenever I change the value to TRUE or FALSE, the rows get rearranged automatically putting rows with set to TRUE at the top.

I want rows to be in the same order as they were.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ketan
  • 3
  • 1

1 Answers1

0

By default, Postgres does not have any specific order at which they return the rows. You can sort your table by a certain column by clicking on the Sort button and specifying the column.

Supabase dashboard

If you want to sort the data that you query from your front end app, you have to add order() clause to sort your result:

const {data, error} = await supabase
  .from('posts')
  .select()
  .order('created_at')
dshukertjr
  • 15,244
  • 11
  • 57
  • 94
  • @Ketan Yeah, the dashboard sorting that I showed is just for the dashboard. If you want your data queried from the frontend to be in a certain order, you have to add `order()` on your query to order your results. I have edited the answer to include a simple sample. – dshukertjr Aug 29 '23 at 06:04