Let's say I have an array of X ids. There is no sequence to them - it is just a list of X random ids.
Now, I want to query X documents using this array, and return it as a SINGLE result - like an array of documents, not make 5 separate queries.
I know I can create a map() function on the fly to do this - essentially looking for documents with an id in the array of ids... but then the query will always be slow. What I'd love to learn how to do is make it fast, like using a secondary index.
Is there a way to do this with PouchDB? And if there isn't a way to do this, how can I easily chain together X promises returned from X queries and group them all in a single result - probably the next best thing?
To search for an array of
_id
s, you can useallDocs()
andkeys
:There's no need for a secondary index, unless you want to search for something other than
_id
. In which case you might look into queries or pouchdb-find.