Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using PouchDB with MongoDB

I've never used CouchDB. I want to use PouchDB on my client app but I'm not sure if it can be integrated with MongoDB because Pouch was designed to be used with CouchDB. Although my API is written in PHP I'm not using any sort of REST API as in CouchDB to connect to the db.

Is there an equivalent of PouchDB that can be used with MongoDB? Or am I going nowhere?

like image 502
astroanu Avatar asked Jun 24 '14 10:06

astroanu


People also ask

Is PouchDB a NoSQL?

PouchDB is a NoSQL database, meaning that you store unstructured documents rather than explicitly specifying a schema with rows, tables, and all that jazz.

Why would you use PouchDB along with CouchDB?

CouchDB and PouchDB are build around the idea of syncing your data. But not only live sync, but losing the connection, and continuing accessing and changing your data. And once your back online, sync it. With PouchDB on the clients browser and CouchDB on the backend your web app can become offline first capable.

What is PouchDB used for?

PouchDB is an in-browser database that allows applications to save data locally, so that users can enjoy all the features of an app even when they're offline. Plus, the data is synchronized between clients, so users can stay up-to-date wherever they go. PouchDB also runs in Node.

Is CouchDB similar to MongoDB?

PouchDB server operating systems are server-less and require a JavaScript environment (browser, Node. js). MongoDB Server operating systems are Solaris, Linux, OS X and Windows.


2 Answers

PouchDB contributor here. :) This is actually a question we get a lot, and it's understandable, given the popularity of MongoDB.

The short answer is: no, there's no way to get a PouchDB that you can just plug into your existing MongoDB database. You might want to try Meteor.js instead.

The long answer is that CouchDB and MongoDB are not equivalent, and in particular CouchDB is designed from the bottom-up to be used for synchronization. There's a good write-up by Jan Lenhardt that explains how it works. Part of the magic of PouchDB/CouchDB sync comes from this design, which Mongo does not have.

In fact, even if PouchDB used Mongo as a backend (which is not outside of the realm of possibility; we already support Redis and Riak), you would not be able to use your existing database as-is, since PouchDB would need to reconstruct this revision-handling schema over Mongo. Hence you would have to rewrite your app to use the PouchDB/CouchDB API.

Update: PouchDB will soon support a Mongo-like query language, via the pouchdb-find plugin.

like image 126
nlawson Avatar answered Oct 05 '22 11:10

nlawson


I saw the minimongo project. I didn't try it yet. As far as I understand it's the same minimongo that is used in the meteor project. The project description says that it has server sync over http. But it doesn't have persistence, indexes.

like image 39
Stanislav Avatar answered Oct 05 '22 11:10

Stanislav