Skip to content

Commit 0d7cb39

Browse files
TimNZflovilmart
authored andcommitted
Support fields in Live Query subscriptions (#518)
1 parent b27ff60 commit 0d7cb39

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/LiveQueryClient.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,17 @@ class LiveQueryClient extends EventEmitter {
182182
if (!query) {
183183
return;
184184
}
185-
let where = query.toJSON().where;
186185
let className = query.className;
186+
let queryJSON = query.toJSON();
187+
let where = queryJSON.where;
188+
let fields = queryJSON.keys ? queryJSON.keys.split(',') : undefined;
187189
let subscribeRequest = {
188190
op: OP_TYPES.SUBSCRIBE,
189191
requestId: this.requestId,
190192
query: {
191193
className,
192-
where
194+
where,
195+
fields
193196
}
194197
};
195198

@@ -271,15 +274,18 @@ class LiveQueryClient extends EventEmitter {
271274
resubscribe() {
272275
this.subscriptions.forEach((subscription, requestId) => {
273276
let query = subscription.query;
274-
let where = query.toJSON().where;
277+
let queryJSON = query.toJSON();
278+
let where = queryJSON.where;
279+
let fields = queryJSON.keys ? queryJSON.keys.split(',') : undefined;
275280
let className = query.className;
276281
let sessionToken = subscription.sessionToken;
277282
let subscribeRequest = {
278283
op: OP_TYPES.SUBSCRIBE,
279284
requestId,
280285
query: {
281286
className,
282-
where
287+
where,
288+
fields
283289
}
284290
};
285291

0 commit comments

Comments
 (0)