Compress the ACL queries into a single $in query (#1566)

This commit is contained in:
Blayne Chard
2016-04-21 01:03:44 +12:00
committed by Florent Vilmart
parent 5d37755d88
commit 54b21c2f73

View File

@@ -823,24 +823,11 @@ function transformNotInQuery(notInQueryObject, className, results) {
}
function addWriteACL(mongoWhere, acl) {
var writePerms = [
{_wperm: {'$exists': false}}
];
for (var entry of acl) {
writePerms.push({_wperm: {'$in': [entry]}});
}
return {'$and': [mongoWhere, {'$or': writePerms}]};
return {'$and': [mongoWhere, {"_wperm" : { "$in" : [null, ...acl]}}]};
}
function addReadACL(mongoWhere, acl) {
var orParts = [
{"_rperm" : { "$exists": false }},
{"_rperm" : { "$in" : ["*"]}}
];
for (var entry of acl) {
orParts.push({"_rperm" : { "$in" : [entry]}});
}
return {'$and': [mongoWhere, {'$or': orParts}]};
return {'$and': [mongoWhere, {"_rperm" : { "$in" : [null, "*", ...acl]}}]};
}
var DateCoder = {