Last active
June 11, 2017 17:16
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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