Home » Php » php – update time of each record in MongoDB

php – update time of each record in MongoDB

Posted by: admin July 12, 2020 Leave a comment

Questions:

MongoDB’s ObjectId has a getTimestamp() method that returns time when the record was inserted. Is there a similar method for getting time of last update or should I use a separate column to save this data?

Using PHP (if it matters).

How to&Answers:

MongoDB doesn’t store the last update so that’s something you’ll have to store yourself through your application in a separate field.