Skip to content

Commit 8f3ea1c

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 4f097ce + 857d4ec commit 8f3ea1c

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ___
1111
- NEW: Added convenience method Parse.Cloud.sendEmail(...) to send email via email adapter in Cloud Code. [#7089](https://github.com/parse-community/parse-server/pull/7089). Thanks to [dblythy](https://github.com/dblythy)
1212
- FIX: Winston Logger interpolating stdout to console [#7114](https://github.com/parse-community/parse-server/pull/7114). Thanks to [dplewis](https://github.com/dplewis)
1313
- NEW: LiveQuery support for $and, $nor, $containedBy, $geoWithin, $geoIntersects queries [#7113](https://github.com/parse-community/parse-server/pull/7113). Thanks to [dplewis](https://github.com/dplewis)
14+
- NEW: Supporting patterns in LiveQuery server's config parameter `classNames` [#7131](https://github.com/parse-community/parse-server/pull/7131). Thanks to [Nes-si](https://github.com/Nes-si)
1415

1516
### 4.5.0
1617
[Full Changelog](https://github.com/parse-community/parse-server/compare/4.4.0...4.5.0)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ You can also use other email adapters contributed by the community such as:
337337
- [parse-server-mailjet-adapter](https://www.npmjs.com/package/parse-server-mailjet-adapter)
338338
- [simple-parse-smtp-adapter](https://www.npmjs.com/package/simple-parse-smtp-adapter)
339339
- [parse-server-generic-email-adapter](https://www.npmjs.com/package/parse-server-generic-email-adapter)
340+
- [parse-server-api-mail-adapter](https://www.npmjs.com/package/parse-server-api-mail-adapter)
340341

341342
### Custom Pages
342343

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"uuid": "8.3.2",
5858
"winston": "3.3.3",
5959
"winston-daily-rotate-file": "4.5.0",
60-
"ws": "7.4.1"
60+
"ws": "7.4.2"
6161
},
6262
"devDependencies": {
6363
"@babel/cli": "7.10.0",

spec/ParseLiveQuery.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,29 @@ describe('ParseLiveQuery', function () {
5656
await object.save();
5757
});
5858

59+
it('can use patterns in className', async done => {
60+
await reconfigureServer({
61+
liveQuery: {
62+
classNames: ['Test.*'],
63+
},
64+
startLiveQueryServer: true,
65+
verbose: false,
66+
silent: true,
67+
});
68+
const object = new TestObject();
69+
await object.save();
70+
71+
const query = new Parse.Query(TestObject);
72+
query.equalTo('objectId', object.id);
73+
const subscription = await query.subscribe();
74+
subscription.on('update', object => {
75+
expect(object.get('foo')).toBe('bar');
76+
done();
77+
});
78+
object.set({ foo: 'bar' });
79+
await object.save();
80+
});
81+
5982
it('expect afterEvent create', async done => {
6083
await reconfigureServer({
6184
liveQuery: {

src/Controllers/LiveQueryController.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export class LiveQueryController {
99
if (!config || !config.classNames) {
1010
this.classNames = new Set();
1111
} else if (config.classNames instanceof Array) {
12-
this.classNames = new Set(config.classNames);
12+
const classNames = config.classNames
13+
.map(name => new RegExp("^" + name + "$"));
14+
this.classNames = new Set(classNames);
1315
} else {
1416
throw 'liveQuery.classes should be an array of string';
1517
}
@@ -43,7 +45,12 @@ export class LiveQueryController {
4345
}
4446

4547
hasLiveQuery(className: string): boolean {
46-
return this.classNames.has(className);
48+
for (const name of this.classNames) {
49+
if (name.test(className)) {
50+
return true;
51+
}
52+
}
53+
return false;
4754
}
4855

4956
_makePublisherRequest(currentObject: any, originalObject: any, classLevelPermissions: ?any): any {

0 commit comments

Comments
 (0)