Reputation: 97
I developing application using mongodb and node js. I want to get document from collection using node js mongoose whenever a new document inserted in the collection(document inserted from python side).Currently, I have query which i run in time interval of 1 seconds using setInterval.
So, Is there any another efficient way without setinterval.
Upvotes: 0
Views: 58
Reputation: 7770
I guess this can be easily achieved by using mongodb change streams.
You can see more about here with code examples.
power of mongodb change streams
Basically listen for insert operation type and react accordingly. This is much efficient then tailing oplog.
Upvotes: 1