I'm new to PouchDB. Now I know how to create DB and how add docs in it. But unlike MySQL, I can't create tables here. One option is to create multiple PouchDBs, which doesn't seem a good idea. I don't want to use CouchDB or something like that.
All I want to use is the localStorage. So say if I have 3 tables in MySQL:
How would I structure the databases so that I can efficiently use find (Query by index) to find the data for a particular table? And is it also possible to define column types like we define in MySQL?
There's something explained here, but the accepted answer suggests using CouchDB, which I don't want currently. I think it's possible merely by localStorage.
Check out this plugin https://github.com/pouchdb-community/relational-pouch. It does exactly what asked -- creates DB schema with multiple tables. It comes through with certain limitations. For example, there is no a direct way now to use find on types, i.e., you'll need to search for all objects and filter by type:
db.find(selector).then(function (data) {
return db.rel.parseRelDocs(type, data.docs);
});`
Also, there might be some potential issues with performance if you create deeply nested structures (async relationships might be helpful).
In general, I believe these issues should not be stoppers with smart design or simple schema.
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