timshannon / badgerhold

BadgerHold is an embeddable NoSQL store for querying Go types built on Badger
MIT License
515 stars 52 forks source link

Load multiple by primary key #35

Closed ivanjaros closed 3 years ago

ivanjaros commented 3 years ago

Since objects are stored by the key that is provided to the crud methods via argument, they do not need to be declared as indices, except "key" which will provided auto-incrementing uin64 index, if needed. I have string primary keys(uuid) so how do I use the Find() method to load multiple objects by their ids? I do not see any method for the query. Do I need to define the index or how does it work?

timshannon commented 3 years ago

Unless I misunderstanding what you're asking, you simple need to use the badgerhold.Key const:

From the README:

image

timshannon commented 3 years ago

You can also use badgerhold.Where(badgerhold.Key).In(1,2,3,4,5)