feat: Add support for $eq query constraint in LiveQuery (#8614)
This commit is contained in:
@@ -125,6 +125,35 @@ describe('matchesQuery', function () {
|
|||||||
expect(matchesQuery(obj, q)).toBe(false);
|
expect(matchesQuery(obj, q)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('matches queries with eq constraint', function () {
|
||||||
|
const obj = {
|
||||||
|
objectId: 'Person2',
|
||||||
|
score: 12,
|
||||||
|
name: 'Tom',
|
||||||
|
};
|
||||||
|
|
||||||
|
const q1 = {
|
||||||
|
objectId: {
|
||||||
|
$eq: 'Person2',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const q2 = {
|
||||||
|
score: {
|
||||||
|
$eq: 12,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const q3 = {
|
||||||
|
name: {
|
||||||
|
$eq: 'Tom',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
expect(matchesQuery(obj, q1)).toBe(true);
|
||||||
|
expect(matchesQuery(obj, q2)).toBe(true);
|
||||||
|
expect(matchesQuery(obj, q3)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it('matches on equality queries', function () {
|
it('matches on equality queries', function () {
|
||||||
const day = new Date();
|
const day = new Date();
|
||||||
const location = new Parse.GeoPoint({
|
const location = new Parse.GeoPoint({
|
||||||
|
|||||||
@@ -247,6 +247,11 @@ function matchesKeyConstraints(object, key, constraints) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case '$eq':
|
||||||
|
if (!equalObjects(object[key], compareTo)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case '$ne':
|
case '$ne':
|
||||||
if (equalObjects(object[key], compareTo)) {
|
if (equalObjects(object[key], compareTo)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user