create()

You can create a data on Schema to database

Syntax

User.create(modelSchema,callback?)
  • modelSchema; This comes from the schema you created.

  • Callback; Callback is a function and not required.

Example

const newUser = {
    name: "John",
    surname: "Doe",
    age: 18
}
User.create(newUser,(callback) => {
console.log("New user created")
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