Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
On MongoDB, update createdAt (or any other field) based on _id's timestamp
db.collection.updateMany({}, [{ $set: { createdAt: { $toDate: "$_id" } } }])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment