-1

whenever any update operation occur on the collection, there should be an automated process in nodejs that will automatically update the timestamp for updateAt field.

I don't want to do manually as there are multiple sources from it can be updated.

MongoDB don't have any trigger, but there is a watch in MongoDB how can I use it.... I want to perform update operations inside the watch and don't want to trigger watch when we update it.

Laxman
  • 1
  • 1
  • Welcome to StackOverflow! Your question is too broad - you need to ask about a specific programming problem you are having, and generally should include information about what you have already tried. https://stackoverflow.com/help/how-to-ask – thelr Jun 15 '20 at 14:27

1 Answers1

0

You can use post update hooks described here But for this particular purpose, you can use { timestamps: true } in your mongoose schema and it will automatically update the createdAt and updatedAt fields

If you are not using mongoose take a look at this question.

Ana Lava
  • 769
  • 1
  • 6
  • 13