Querying Your PouchDB Database With SQL
Adapting the simple SQL support in my silverlining npm module to work with in-browser database PouchDB
I blogged recently about querying a Cloudant (and CouchDB 2.0) database with SQL by using the silverlining library to convert SQL queries into a form of JSON that the database can understand.
What about PouchDB?
So can PouchDB databases be queried using SQL too? Yes!
The pouchdb-silverlining npm module builds on pouchdb-find to provide SQL support in PouchDB through a new
.sql() function in your Node.js code:
PouchDB.find is the future
The PouchDB roadmap has the
find function as the default means of querying the database. The MapReduce-based
query function will be relegated to a plugin, so when PouchDB hits version 7, the pouchdb-silverlining plugin may not require the pouchdb-find plugin as a dependency, because it will be built in to the product.
If you’re interested in how SQL is converted into Mango JSON, then you can read the code in the sqltomango module, which is used by both Silverlining libraries.
If you enjoyed this article, please ♡ it to recommend it to other Medium readers.