我正在尝试让pouchDB和本地couchDB之间的同步()在一个角应用程序中工作(使用角-pouchdb)。
this.system = pouchDB('system');
var remoteSystem = pouchDB('http://localhost:5984/system');
this.system.sync(remoteSystem, {live : true}).on('change', function (change) {
// yo, something changed!
console.log('changed');
}).on('error', function (err) {
// yo, we got an error!
console.log('error');
});但我不断地发现以下错误:
Uncaught TypeError: undefined is not a function (angular.js:4146)如果我删除了.on链,错误就会消失(但是同步仍然不起作用)
发布于 2015-01-22 15:12:21
如果您使用的是angular-pouchdb,那么pouchdb对象实际上不是PouchDB对象;它是一个特殊的angular-pouchdb对象。
幸运的是,sync和replicate API也可以在数据库本身上使用。所以你可以:
local.sync(remote, { live: true})也是一样的事。
发布于 2015-01-22 12:42:35
PouchDB的最新版本在PouchDB对象上具有同步方法。
var remote = new PouchDB('http://localhost:5984/system');
var local = new PouchDB('system');
PouchDB.sync(local, remote, { live: true })
.on('change', function (info) {
// handle change
}).on('complete', function (info) {
// handle complete
}).on('uptodate', function (info) {
// handle up-to-date
}).on('error', function (err) {
// handle error
});https://stackoverflow.com/questions/28075123
复制相似问题