Reputation: 3288
Context:
I have a nodejs app which is inserting documents to a mongoDB.
I have users who create custom queries to this mongodb to find documents. I also use change streams to live feed updates to them.
I'm using the mongodb 3.6.2 nodejs driver.
Question:
It could be possible for me to remove the change streams if I could check if the document I was inserting matched one of my user's queries.
For example, let's say a user was interested in documents that matched the query { "foo": "bar" }
. If I insert a document { "baz": 1, "foo": "bar" }
, I could send that document down the wire to the user and not need to rely on my change stream to listen for the insert.
Is there any way for me (in javascript) to match an object against a query so that I don't need to rely on my change stream?
EDIT
var matcher = new Minimongo.Matcher({a: {$gt: 5}}); if (matcher.documentMatches({a: 7})) ...
Upvotes: 1
Views: 165