将PouchDB与MongoDB结合使用 [英] Using PouchDB with MongoDB

查看:93
本文介绍了将PouchDB与MongoDB结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从未使用过CouchDB.我想在客户端应用程序上使用PouchDB,但是我不确定它是否可以与MongoDB集成,因为Pouch是为与CouchDB一起使用而设计的.尽管我的API是用PHP编写的,但我没有像在CouchDB中那样使用任何类型的REST API来连接数据库.

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.

是否有可与MongoDB一起使用的PouchDB?还是我无处可去?

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

推荐答案

此处的PouchDB贡献者. :)考虑到MongoDB的流行,这实际上是一个很多问题,这是可以理解的.

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

简单的答案是:不,没有办法获得可以直接插入现有MongoDB数据库的PouchDB.您可能想尝试 Meteor.js .

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.

长答案是CouchDB和MongoDB不等效,尤其是CouchDB是自下而上设计的,用于同步. Jan Lenhardt撰写的精彩文章解释了它的工作原理. PouchDB/CouchDB同步的部分魔力来自这种设计,而Mongo则没有.

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.

事实上,即使PouchDB使用Mongo作为后端(这也不在可能范围之内; 我们已经支持Redis和Riak ),您将无法按原样使用现有数据库,因为PouchDB需要在Mongo上重建此修订处理架构.因此,您必须重写您的应用程序才能使用PouchDB/CouchDB API.

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.

更新:PouchDB即将通过 pouchdb-find插件支持类似Mongo的查询语言. .

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

这篇关于将PouchDB与MongoDB结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆