0

I have been trying to create a live query on a Parse server using a subscription, but it seems like some events are not triggered.

I log every event that the subscription receives, and I know that 'open' is triggered. However, I do not receive any other events when I change data that should influence the query result. I enabled live query classes on the backend for CanvasVersion and Sticky on a Sashido Parse server.

This is the client code:

const relation = this.canvasVersion.stickies;
const query = relation.query();
query.equalTo("segment", this.id);

this.segmentUpdatedSubscription = await query.subscribe();

this.segmentUpdatedSubscription.on('open', () => {
    console.log('Subscription opened');
})

this.segmentUpdatedSubscription.on('error', (error) => {
    console.log('error', error);
})

this.segmentUpdatedSubscription.on('create', (sticky) => {
    console.log('Created: ' + sticky);
});

Continuing for 'update', 'enter', 'delete', 'leave' and 'close', where this.canvasVersion.stickies is a relation between the canvasVersion and Sticky objects.

The parse server is initialized with the following code:

static initialize() {
   Parse.initialize(environment.parse.appId, environment.parse.appKey);
   (Parse as any).serverURL = environment.parse.serverURL;
}

Does someone know why these events are not triggered and how I can solve it? Thanks in advance for the help.

MsBlueSky
  • 31
  • 5

1 Answers1

0

Parse subscribe (Parse LiveQuery) is not support relation subscription.

https://github.com/parse-community/parse-server/issues/5610#issuecomment-495277400

Use subscribe a normal way with conditions.

const query = Parse.Object.extend('Sticky').query();
query.equalTo("segment", this.id);

const segmentUpdatedSubscription = await query.subscribe();
Jeff Gu Kang
  • 4,749
  • 2
  • 36
  • 44