.update()
Update a document
Parameter
Description
_id
The id of the document that will be updated
values
Values that will be updated
update({ _id }, values)
User.update({ _id: 1 }, { username: "len" }).save()
// {
// _id: 1,
// username: "len"
// }
Or update a user from find: Using find() and update()
const userFound = User.find({ _id: 1 })
userFound.update({ username: "len" }).save()
// {
// _id: 1,
// username: "len"
// }
Using only find() and updating the data directly
const userFound = User.find({ _id: 1 })
userFound.username = "len"
userFound.save()
// {
// _id: 1,
// username: "len"
// }
Last updated
Was this helpful?