DEV Community

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

Posted on • Edited on

1 1

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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay