Using PouchDB with MongoDB
Asked Answered
F

2

35

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?

Forsook answered 24/6, 2014 at 10:55 Comment(0)
J
77

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.

Jauch answered 24/6, 2014 at 17:6 Comment(5)
Interesting. its nice to know the things right from the source. :)Forsook
I'm not sure I understand why Redis and Riak can be supported but not MongoDB. If anything, MongoDB sounds like much less work to implement under the hood for a CouchDB-like server such as pouchdb-server.Horologium
Redis and Riak are "supported" in the sense that PouchDB can use them as a storage engine. It's only really interesting for academic reasons, though; you wouldn't want to actually use it in production, because PouchDB is basically using them as dumb key-value stores, and you can't actually directly use those databases - instead you need to use PouchDB's abstraction over them. The link above explains the concepts.Jauch
Wow, update seems interesting as Azure Cosmos also can use Mongo API to access it... #goodtimesGlia
What if we dont use it's sync feature and just get data using db.get() after then we simply call POST API to add out data to MongoDB. Is it a good approach?Indistinguishable
N
1

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.

Nelsonnema answered 8/9, 2015 at 14:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.