I come from a Mysql background and I'm using Pouchdb now. I'm used to the SQL pattern of having 1 database and many tables per app.
In pouchDB it's different, because data is not stored in tables but in documents. So, in my app, I have a database for tasks, created with:
var db = new PouchDB('tasks', {revs_limit: 1, auto_compaction: true});
This is the main database for my application, but now I need to also store settings, such as "last_visit_date", "language_preference" and others.
So, I have 2 questions:
Is creating multiple PouchDB databases on the same application considered bad design?
In a word: No.
Long answer: Databases in CouchDB/PouchDB are essentially free. And some application designs require multiple databases.
Consider a theoretical Offline-first/mobile app which tracks an agent's sales. It may have a database for inventory management purposes, which is synchronized with a central CouchDB server.
It will likely also have a per-agent database, with client and sales info for a given agent.
The PouchDB app will need both databases. And due to the design of CouchDB, there's no (easy, sane) way to keep those data sets in the same database, and keep agent's records separate from each other.
Databases in CouchDB/PouchDB are more like tables than databases in an RDBMS.
The only real limiting factor for creating additional databases in PouchDB (which doesn't apply to CouchDB), is that there's no easy way to list your existing databases, except with the use of plugin. This needn't be a real limitation--it just means you need to remember which databases you've created (you probably shouldn't be programatically creating randomly-named databases... but that would probably be a bad design anyway. ;-) )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With