DEV Community

Cover image for Which is better in MongoDB
Ifeanyi Chima
Ifeanyi Chima

Posted on • Edited on

Which is better in MongoDB

Which is better in MongoDB to use when saving documents ?

Image description

Save


const data = { "name": "Jerry", "password": "#343@" };

const newUser = new User(data);

const result = await newUser.save()

Enter fullscreen mode Exit fullscreen mode

Create


const result = await User.create({
  "name": "Jerry", "password": "#343@"
})

Enter fullscreen mode Exit fullscreen mode

Buy Me A Coffee

Thank you, please follow me

HTML GitHub

Top comments (0)