Márcio Moreira
Márcio Moreira

Reputation: 505

Multiple data collections in Pouchdb

In Pouchdb, what can be the best way to handle multiple data collections? I mean, for example, that instead of a simple to-do list, I need multiple to-do lists, like: home to-do, work to-do, community to-do, and ecology to-do.

Should I put it all inside one db and use one key in each doc to determine which list it belongs to? Or should I use different db's? In my app the user will be able to freely create and remove those data collections (or to-do lists, in the example).

Thank you, Marcio Moreira

Upvotes: 5

Views: 2516

Answers (1)

nlawson
nlawson

Reputation: 11620

You can add a "type" field to each document, or you can prefix the _id of the document (e.g. home_1, home_2, etc.). The advantage of the second strategy is that you don't need to create a secondary index, and can just use allDocs() to find e.g. all todos of type "home."

Upvotes: 8

Related Questions