editing docs
change the
error field of all docs
function(doc) {
doc.error *= 100;
return doc;
}
rename
message field in all docs
function(doc) {
doc.text = doc.message;
delete doc.message;
return doc;
}
deleting docs
delete all docs that have
year less than 2010
function(doc) {
if(doc.year < 2010)
return null;
}
cut docs in db down to the first thousand
function(doc) {
i = i + 1 || 1;
if(i > 1000)
return null;
}
adding docs
add a doc to the db
{
"name": "newdoc",
"message": "addin"
}
add three docs to the db
{"name": "doc1","message": "addin"},
{"name": "doc2", "count": 20},
{"name": "doc3", "count": 14}