Adding Mongodb element to add arrayMatches the #4762 (#4766)

* Adding elemMatch and nor

* lint

* adding test

* adding edge test

* postgres support

* clean up

* empty test
This commit is contained in:
Jérémy Piednoel
2018-05-18 09:35:50 -04:00
committed by Diamond Lewis
parent ad244d6654
commit c0f86ae1d1
3 changed files with 133 additions and 0 deletions

View File

@@ -290,6 +290,9 @@ function transformQueryKeyValue(className, key, value, schema) {
if (transformedConstraint.$text) {
return {key: '$text', value: transformedConstraint.$text};
}
if (transformedConstraint.$elemMatch) {
return { key: '$nor', value: [{ [key]: transformedConstraint }] };
}
return {key, value: transformedConstraint};
}
@@ -797,6 +800,19 @@ function transformConstraint(constraint, field) {
answer[key] = s;
break;
case '$containedBy': {
const arr = constraint[key];
if (!(arr instanceof Array)) {
throw new Parse.Error(
Parse.Error.INVALID_JSON,
`bad $containedBy: should be an array`
);
}
answer.$elemMatch = {
$nin: arr.map(transformer)
};
break;
}
case '$options':
answer[key] = constraint[key];
break;