findById()

You can find a data on Schema by ID

Syntax

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

  • Callback; Callback is a function and not required.

Example

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

Last updated