Open jiayuxiaochaoren opened 12 months ago
So there is a way to do this. If you look at this file on line 343:
func (b *SelectRequestBuilder) OrderBy(column, direction string) *SelectRequestBuilder {
b.params.Set("order", column+"."+direction)
return b
}
The way it would be used is:
var results []interface{}
client := supa.CreateClient(supabase_url, supabase_key)
err := client.DB.From(tableName).Select("*").OrderBy("name", "asc").ExecuteWithContext(ctx, &results)
log.Info("results", results)
However, this addition hasn't been added to the latest tags/ releases of postgres-go so you currently can't do it until @nedpals adds the new tag.
I did push this PR though, so that the function would work this way since the order
parameter is just a binary function at the end of the day.
If accepted the function would work like this:
var results []interface{}
client := supa.CreateClient(supabase_url, supabase_key)
// true for ascend
// false for descend
err := client.DB.From(tableName).Select("*").OrderBy("name", true).ExecuteWithContext(ctx, &results)
log.Info("results", results)
``
I want to get latest record,but i don't know how to query to meet such needs.