样品大CouchDB数据库用于当地的发展,避免长图建立
-
25-09-2019 - |
题
CouchDB便发展(CouchApps)在当地,然后推进到偏远的生产。不幸的是与生产大小的数据集,工作上的意见可能比较麻烦。
什么是好的方式采取的样品的一个CouchDB数据库用于当地的发展?
解决方案
答案是过滤后的复制。我喜欢做这两个部分:
- 复制生产数据库,
example_db
我当地的服务器example_db_full
- 执行过滤的复制
example_db_full
要example_db
, ,在这里过滤器减少了足够的数据,以便建立快速,但保留足够的数据,因此我可以证实我的代码的工作。
该文件的选择可以是具体应用。在这个时候,我很满意的一个简单的随机的通过/未通过一个百分比,我可以指定。随机性是一致的(即,同一文件中始终是通过总是失败。)
我的技术规范的内容校验和在该文件 _rev
场上一系列的[0.0,1.0).然后我只需指定一些部分(例如 0.01
),而如果化验和值是 <=我的分数,该文件通过。
function(doc, req) {
if(/^_design\//.test(doc._id))
return true;
if(!req.query.p)
throw {error: "Must supply a 'p' parameter with the fraction"
+ " of documents to pass [0.0-1.0]"};
var p = parseFloat(req.query.p);
if(!(p >= 0.0 && p <= 1.0)) // Also catches NaN
throw {error: "Must supply a 'p' parameter with the fraction of documents"
+ " to pass [0.0-1.0]"};
// Consider the first 8 characters of the doc checksum (for now, taken
// from _rev) as a real number on the range [0.0, 1.0), i.e.
// ["00000000", "ffffffff").
var ONE = 4294967295; // parseInt("ffffffff", 16);
var doc_val = parseInt(doc._rev.match(/^\d+-([0-9a-f]{8})/)[1], 16);
return doc_val <= (ONE * p);
}
不隶属于 StackOverflow