DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

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

Posted on • Updated 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

linkedin
github

Top comments (0)

An Animated Guide to Node.js Event Lop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.