Export and Import a CouchDB database
If you are looking at this article you probably know what CouchDB is, but a little foreword won’t hurt anyone.
Apache CouchDB is an open-source document-oriented NoSQL database. It is using JSON as a data storage format, JavaScript as its query/data manipulation language and leveraging HTTP to expose a REST API interface to interact directly with it.
Cool, this REST API interface is exactly what we need for our purpose, which is moving data back and forth between different hosts and/or databases.
API to use
This is gonna be pretty much easy because we need just two APIs:
What we have to do
This task is straightforward as well. We have a bunch of operation to do and all in series:
The program
This little program is coded in JavaScript and runs directly with Node, there isn’t the need for any further dependency, so it’s cool, you just need Node. I mean… not because packages suck. I am actually in love with NPM but I thought it would have been better to have something ready-to-go for this tutorial.
If you think you can make it better or have any suggestions, just comment here or on my Gist.
Made with love, enjoy!