使用PouchDB过滤设计文档 [英] Filter design documents with PouchDB

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

问题描述

我正在使用设计文档来确保只有所有者才能修改文档。我可以使用 replicate()中的 rel =nofollow code $,例如

$ pre $ var $ op
$ live $ true
filter:function (doc){
return doc._id.indexOf('_ design')!== 0;
}
};
var db = new PouchDB('todos');
db.replicate.to('http:// localhost:5984 / todos',opts);


I'm using a design document to ensure that only owners can modify docs. How can I prevent couchdb from replicating this design document?

解决方案

You can use the filter option in changes() and replicate(), e.g.

var opts = {
  live: true,
  filter: function(doc) {
    return doc._id.indexOf('_design') !== 0;
  } 
};
var db = new PouchDB('todos');
db.replicate.to('http://localhost:5984/todos', opts);

这篇关于使用PouchDB过滤设计文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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