Skip to content

Commit 54b21c2

Browse files
blachaflovilmart
authored andcommitted
Compress the ACL queries into a single $in query (#1566)
1 parent 5d37755 commit 54b21c2

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/Adapters/Storage/Mongo/MongoTransform.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -823,24 +823,11 @@ function transformNotInQuery(notInQueryObject, className, results) {
823823
}
824824

825825
function addWriteACL(mongoWhere, acl) {
826-
var writePerms = [
827-
{_wperm: {'$exists': false}}
828-
];
829-
for (var entry of acl) {
830-
writePerms.push({_wperm: {'$in': [entry]}});
831-
}
832-
return {'$and': [mongoWhere, {'$or': writePerms}]};
826+
return {'$and': [mongoWhere, {"_wperm" : { "$in" : [null, ...acl]}}]};
833827
}
834828

835829
function addReadACL(mongoWhere, acl) {
836-
var orParts = [
837-
{"_rperm" : { "$exists": false }},
838-
{"_rperm" : { "$in" : ["*"]}}
839-
];
840-
for (var entry of acl) {
841-
orParts.push({"_rperm" : { "$in" : [entry]}});
842-
}
843-
return {'$and': [mongoWhere, {'$or': orParts}]};
830+
return {'$and': [mongoWhere, {"_rperm" : { "$in" : [null, "*", ...acl]}}]};
844831
}
845832

846833
var DateCoder = {

0 commit comments

Comments
 (0)