Compress the ACL queries into a single $in query (#1566)
This commit is contained in:
committed by
Florent Vilmart
parent
5d37755d88
commit
54b21c2f73
@@ -823,24 +823,11 @@ function transformNotInQuery(notInQueryObject, className, results) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addWriteACL(mongoWhere, acl) {
|
function addWriteACL(mongoWhere, acl) {
|
||||||
var writePerms = [
|
return {'$and': [mongoWhere, {"_wperm" : { "$in" : [null, ...acl]}}]};
|
||||||
{_wperm: {'$exists': false}}
|
|
||||||
];
|
|
||||||
for (var entry of acl) {
|
|
||||||
writePerms.push({_wperm: {'$in': [entry]}});
|
|
||||||
}
|
|
||||||
return {'$and': [mongoWhere, {'$or': writePerms}]};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addReadACL(mongoWhere, acl) {
|
function addReadACL(mongoWhere, acl) {
|
||||||
var orParts = [
|
return {'$and': [mongoWhere, {"_rperm" : { "$in" : [null, "*", ...acl]}}]};
|
||||||
{"_rperm" : { "$exists": false }},
|
|
||||||
{"_rperm" : { "$in" : ["*"]}}
|
|
||||||
];
|
|
||||||
for (var entry of acl) {
|
|
||||||
orParts.push({"_rperm" : { "$in" : [entry]}});
|
|
||||||
}
|
|
||||||
return {'$and': [mongoWhere, {'$or': orParts}]};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var DateCoder = {
|
var DateCoder = {
|
||||||
|
|||||||
Reference in New Issue
Block a user