updateById()

You can update a data on Schema

Syntax

User.updateById(id,newData,callback?)
  • Id; ID is a string and required.

  • NewData; New data must contain one or more of the userSchemas properties.

  • Callback; Callback is a function and not required.

Example

const id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
const newData = {
  age:19
}
User.updateById(id,newData,(callback) => {
console.log("Happy birthday John")
console.log(callback)
/*
{
  id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
  name: 'John'
  surname: 'Doe',
  age: 19,
  updatedAt: 1970-01-01T00:00:00.000Z,
  createdAt: 1970-01-01T00:00:00.000Z
}
*/
})

Last updated