Add a new trigger beforeLiveQueryEvent
#9431
Labels
bounty:$20
Bounty applies for fixing this issue (Parse Bounty Program)
type:feature
New feature or improvement of existing feature
New Feature / Enhancement Checklist
Current Limitation
As of today, as soon as you declare a className in the
new ParseServer({ liveQuery: { classNames: [...] }})
all events are systematically published through the PubSubAdapter (Redis for example). Then the LiveQuery server receives the event and depending on the subscriptions it evaluates which Livequery clients should receive a message through WebSocket.We encountered a limitation because sometimes we would like to limit the events sent to the LiveQuery server since it can consume a lot of CPU to evaluate all the subscriptions.
Feature / Enhancement Description
The idea would be to implement a "beforeLiveQueryEvent" that would prevent a publish depending on some business logic.
I think the main location of the code would be in this section :
parse-server/src/RestWrite.js
Lines 1630 to 1644 in 91f9aca
If a
beforeLiveQueryEvent
trigger is defined that the className has LiveQuery then you would pass in the function, if the function return undefined you would prevent the liveQueryController.onAfterSaveExample Use Case
For example, we don't want the LiveQuery server to treat in real time some object that would have a
status === 'draft'
because our business logic don't depend on it even though a lot of object are created with this status.Alternatives / Workarounds
There is none at the moment since you activate globally to the className.
3rd Party References
No
The text was updated successfully, but these errors were encountered: