ostafen / clover

A lightweight document-oriented NoSQL database written in pure Golang.
MIT License
680 stars 55 forks source link

Implement sorting #13

Closed jsgm closed 2 years ago

jsgm commented 2 years ago

Hello,

It would be a good idea to have the possibility of sorting the different FindAll() results.

In order to don't make the code complex, here are a few simple ideas for sorting results numerically and alphabetically that would be useful to implement: db.Query("todos").Where(c.Field("completed").Eq(true).And(c.Field("userId").In(5, 8))).FindAll().SortAsc("userId") and SortDesc db.Query("todos").Where(c.Field("completed").Eq(true).And(c.Field("userId").In(5, 8))).FindAll().Sort("userId", 1) or -1

ostafen commented 2 years ago

@jsgm: check 07c2f731a6e869f5fdec1bd5467b18054c58dcc8 Let me know what you think about the APIs (you can use function TestSort as a reference)