0 votes
1 view
in Web Technology by (28.9k points)

I want to know what is the exact difference between "save" and "insert" command in MongoDB? For me, both syntaxes look the same:

db.users.save({username:"google",password:"google123"})

db.users.insert({username:"google",password:"google123"})

Please guide me:-)

1 Answer

0 votes
by (63.8k points)
edited ago by

The instances that you have provided, the action for both save and insert is essentially the same because as the document provided in 'save' has no _id field.

But the main difference between 'save' and 'insert' command is that the 'save' command can insert or update a document whereas 'insert' only performs the insertion.

Related questions

0 votes
2 answers
asked Oct 16, 2019 in Web Technology by Sammy (47.8k points)
0 votes
1 answer
0 votes
2 answers
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...