我正在使用以下地图功能从组中获取“链接”到的用户文档:
function(doc) {
var i, id;
if(doc.type == 'group' && !doc.deletedAt) {
for (i = 0; i < doc.users.length; ++i) {
id = doc.users[i];
emit(doc._id, {'_id': id});
}
emit(doc._id, null);
}
}
一组看起来像:
{
"_id": "3979684300c58a4c90c7c6e0d6033dce",
"_rev": "90-283daf6cb4edfd838a50121e3364f4cb",
"type": "group",
"name": "test",
"description": "test",
"users": [
"544f4718732b51506d9de60a4e000505",
"63de6351a30879ee091b248c930a9254",
"5684612479ba328ba2575c60e800adee"
],
... other fields
}
用户看起来像:
{
"_id": "8f87c698f119044890c5e788cd0028c1",
"_rev": "5-441da938e50fb692da55d74231f614c2",
"empId": "",
"type": "user",
"disabled": false,
"username": "fred",
"firstName": "Fred",
"lastName": "Jones",
...other fields
}
地图功能有效,但我需要过滤掉设置了“deletedAt”属性的用户文档。这在地图功能中可能吗?