Skip to content

Instantly share code, notes, and snippets.

@RoyalHunt
Created April 2, 2018 20:39
Show Gist options
  • Save RoyalHunt/b07ea0c71d4c9adf1810f9e30717cf22 to your computer and use it in GitHub Desktop.
Save RoyalHunt/b07ea0c71d4c9adf1810f9e30717cf22 to your computer and use it in GitHub Desktop.
update all documents in mongodb
const test = await User.find()
test.forEach(async (doc) => {
const id = nanoid()
await User.update({ _id: doc._id }, { $set: { id } })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment