Skip to content

Instantly share code, notes, and snippets.

@nateplusplus
Last active June 11, 2017 17:16
Show Gist options
  • Save nateplusplus/ddd789fd5f23a49e1b7f3a13f6785bc8 to your computer and use it in GitHub Desktop.
Save nateplusplus/ddd789fd5f23a49e1b7f3a13f6785bc8 to your computer and use it in GitHub Desktop.
Creating a new database, collection, and document in MongoDB, read more at: http://natehub.blogspot.com/2017/06/learning-mongodb-from-mysql-background.html
// Create and enter new database
use scorecard
// Create new collection named "scorecards" within database "scorecard"
db.createCollection('scorecards');
// Insert data into scorecards collection
db.scorecards.insert({
"title": "Bacon Pancakes",
"players": [
{
"id": 0,
"name": "Finn",
"score": 0
},
{
"id": 1,
"name": "Jake",
"score": 0
}
],
"created": ISODate(),
"modified": ISODate(),
"deleted": 0
});
// View all records in scorecards collection
db.scorecards.find();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment