timshannon / bolthold

BoltHold is an embeddable NoSQL store for Go types built on BoltDB
MIT License
643 stars 45 forks source link

Q: limit query without conditions #121

Closed ivanjaros closed 3 years ago

ivanjaros commented 3 years ago

I don't see any way to load results with pagination(ie. offset + limit) without starting a query with Where() which requires a field to apply a condition onto. Am I missing something here?

In other words I just want equivalent of SELECT * FROM foo ORDER BY id ASC LIMIT 0,25

timshannon commented 3 years ago

You can create an empty query that matches against everything the same way you create any empty object in Go. The best place to find example queries is in the tests (https://github.com/timshannon/bolthold/blob/master/find_test.go#L402)

(&bolthold.Query{}).Skip(0).Limit(25).SortBy("ID")
ivanjaros commented 3 years ago

ok, i wasn't sure it would work. thanks.