How to listen for changes to a MongoDB collection?

后端 未结 11 1687
不思量自难忘°
不思量自难忘° 2020-11-22 06:08

I\'m creating a sort of background job queue system with MongoDB as the data store. How can I \"listen\" for inserts to a MongoDB collection before spawning workers to proce

11条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 06:40

    Actually, instead of watching output, why you dont get notice when something new is inserted by using middle-ware that was provided by mongoose schema

    You can catch the event of insert a new document and do something after this insertion done

提交回复
热议问题