Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
return valueFilter(val, options, populateOptions);
}
for (let i = 0; i < docs.length; ++i) {
const existingVal = utils.getValue(o.path, docs[i]);
if (existingVal == null && !getVirtual(o.originalModel.schema, o.path)) {
continue;
}
let valueToSet;
if (count) {
valueToSet = numDocs(rawIds[i]);
} else if (Array.isArray(o.match)) {
valueToSet = Array.isArray(rawIds[i]) ?
sift(o.match[i], rawIds[i]) :
sift(o.match[i], [rawIds[i]])[0];
} else {
valueToSet = rawIds[i];
}
// If we're populating a map, the existing value will be an object, so
// we need to transform again
const originalSchema = o.originalModel.schema;
const isDoc = get(docs[i], '$__', null) != null;
let isMap = isDoc ?
existingVal instanceof Map :
utils.isPOJO(existingVal);
// If we pass the first check, also make sure the local field's schematype
// is map (re: gh-6460)
isMap = isMap && get(originalSchema._getSchema(o.path), '$isSchemaMap');
if (!o.isVirtual && isMap) {
return valueFilter(val, options, populateOptions);
}
for (let i = 0; i < docs.length; ++i) {
const existingVal = utils.getValue(o.path, docs[i]);
if (existingVal == null && !getVirtual(o.originalModel.schema, o.path)) {
continue;
}
let valueToSet;
if (count) {
valueToSet = numDocs(rawIds[i]);
} else if (Array.isArray(o.match)) {
valueToSet = Array.isArray(rawIds[i]) ?
sift(o.match[i], rawIds[i]) :
sift(o.match[i], [rawIds[i]])[0];
} else {
valueToSet = rawIds[i];
}
// If we're populating a map, the existing value will be an object, so
// we need to transform again
const originalSchema = o.originalModel.schema;
const isDoc = get(docs[i], '$__', null) != null;
let isMap = isDoc ?
existingVal instanceof Map :
utils.isPOJO(existingVal);
// If we pass the first check, also make sure the local field's schematype
// is map (re: gh-6460)
isMap = isMap && get(originalSchema._getSchema(o.path), '$isSchemaMap');
if (!o.isVirtual && isMap) {
const _keys = existingVal instanceof Map ?
EACH(storage, (data, id) => {
if (Sift(filter)(data) === true) {
result[id] = data;
}
});
dsFind: function (_a) {
var type = _a.type, collectionName = _a.collectionName, query = _a.query, multi = _a.multi;
var found = (adapter.get(collectionName) || []).filter(sift_1.default(query));
return found.length ? multi ? found : [found[0]] : [];
},
dsInsert: function (_a) {
const buildPatternBasedRequestMatcher = pattern => {
const siftMatcher = sift(pattern);
return req => siftMatcher(prepareRequestForMatching(req));
};
resolved: new Date('December 17, 1997 03:24:00'),
artifacts: {},
},
workerPool: 'banana',
providerId: 'gcp',
latestTaskStatus: 'great success',
quarantineUntil: new Date('December 17, 2095 03:24:00'),
recentErrors: 2,
latestStarted: new Date(),
latestResolved: new Date(),
},
];
return filter ? Promise.resolve(sift(filter, summaries)) : Promise.resolve(summaries);
})
);
module.exports = function compileQuery(queryObj = {}) {
return sift(preprocessQueryObj(queryObj));
};
dsRemove: function (_a) {
var type = _a.type, collectionName = _a.collectionName, query = _a.query;
var collection = adapter.get(collectionName) || [];
var filter = sift_1.default(query);
var ret = [];
for (var i = collection.length; i--;) {
var item = collection[i];
if (filter(item)) {
ret.push(item);
collection.splice(i, 1);
}
}
adapter.set(collectionName, collection);
return ret;
}
}); }); };