MongoDB Tutorial: How To Write To A Database In MongoDB

By Nicholas Brown – Follow me on Twitter.

<< 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});