Empowering you to understand your world

MongoDB Tutorial: How To Write To A Database In MongoDB

By Nicholas Brown.

<< Back To MongoDB Read Operations

MongoDB CRUD Operations: Save A Record

Now go ahead and enter some records into the database by typing the commands below. That’s called a MongoDB write operation. It makes for good practice, and we will update one of these records to make comparisons easier. Also remember that these commands must be typed at a Mongo client prompt. So if you closed the terminal window or exited the Mongo client, relaunch it.

db.fruits.insert({Name: 'Orange', PotassiumContent: 237, ServingSize: 131});

db.fruits.insert({Name: 'Kidney Beans', PotassiumContent: 405, ServingSize: 100});


Subscribe to our newsletter
Get notified when new content is published