forked from Meteor-Community-Packages/meteor-partitioner
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommon.js
26 lines (25 loc) · 957 Bytes
/
common.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
ErrMsg = {
userIdErr: "Must be logged in to operate on partitioned collection",
groupErr: "Must have group assigned to operate on partitioned collection",
multiGroupErr: "Attempted to apply multi-group operation on a single-group collection. Pass multiGroups: true to Partitioner.Partitioner options",
};
Helpers = {
isDirectSelector(selector) {
return selector && (
typeof(selector)==='string'
|| typeof(selector._id)==='string'
);
},
// Because of https://github.com/HarvardEconCS/turkserver-meteor/issues/44
// _id: { $in: [ ... ] } queries should be short-circuited as well for users
isDirectUserSelector(selector) {
return selector && (
typeof(selector)==='string'
|| typeof(selector._id)==='string'
|| typeof(selector.username)==='string'
|| typeof(selector['emails.address']) === 'string'
// null is type 'object'
|| (typeof(selector._id)==='object' && selector._id!=null && selector._id.$in!=null)
);
}
};