
Set 1 consists of seven lines of terminal window command with a note: 1 MongoDB daemon process needs to be started in a separate terminal window. Line 1: tilde forward slash workspace dollar mongod. Line 2: mongo d hyphen hyphen help for help and startup options. Line 3: 2016 hyphen 08 hyphen 0320:14:00. 020 plus 0000 open square bracket initandlisten close square bracket MongoDB starting colon dots. Line 4: 2016 hyphen 08 hyphen 03720:14:00. 020 plus 0000 open square bracket initandlisten close square bracket db version v2. 6. 11. Line 5: 2016 hyphen 08 hyphen 03120:14:00. 020 plus 0000 open square bracket initandlisten close square bracket git version colon dots. Line 6: dots. Line 7: 2016 hyphen 08 hyphen 04717: 00: 49. 737 plus 0000 open square bracket initandlisten close square bracket waiting for connections on port 27017.
Set 2 consists of 31 lines of terminal window command, starting with a note: 2 the MongoDB shell in another window lets you work with the data. Line 1: tilde forward slash workspace dollar mongo. Line 2: MongoDB shell version: 2. 6. 11. Line 3: connecting to: test. Line 4: greater than sign use funwebdev.
Note: This line specifies the databse to use open parenthesis if it does not exist it gets created close parenthesis. Line 5: switched to db funwebdev. Line 6: greater than sign db dot art dot insert open parenthesis open curly brace open double quotes i d close double quotes colon 438, open double quotes title close double quotes colon open double quotes Starry Night close double quotes close curly brace close parenthesis. Note 1: open double quotes art close double quotes specifies the collection to use open parenthesis if it does not exist it gets created close parenthesis. Note 2: open double quotes insert close double quotes adds new document. Line 7: WriteResult open parenthesis open curly brace open double quotes nInserted close double quotes: 1 close curly brace close parenthesis. Line 8: greater than sign db dot art dot insert open parenthesis open curly brace i d colon 400, title colon open double quotes The School of Athens close double quotes close curly brace close parenthesis. Note: Line fifth and Line seventh open double quotes title close double quotes are marked in grey background with text: open double quotes Quotes around property names are optional close double quotes. Line 9: WriteResult open parenthesis open curly brace open double quotes nInserted close double quotes colon 1 close curly brace close parenthesis. Line 10: greater than sign. Line 11: greater than sign for open parenthesis var i equals 1 semicolon i less than equals 10 semicolon i plus plus close parenthesis db dot users dot insert open parenthesis open curly brace Name colon open double quotes User close double quotes plus i comma i d colon i close curly brace close parenthesis. Note: The MongoDB shell is like the JavaScript console: you can write any valid JavaScript code. Line 12: greater than sign. Line 13: db dot art dot find open parenthesis close parenthesis. Note: returns all data in specified collection. Line 14: open curly brace open double quotes underscore i d close double quotes colon ObjectId open parenthesis open double quotes 57a3780476 ellipsis close double quotes close parenthesis comma open double quotes i d close double quotes colon 438, open double quotes title close double quotes colon open double quotes Starry Night close double quotes close curly brace. Line 15: open square bracket open double quotes underscore i d close double quotes colon ObjectId open parenthesis open double quotes 57a378 ellipsis close double quotes close parenthesis comma open double quotes i d close double quotes colon 400, open double quotes title close double quotes colon open double quotes The School of Athens close double quotes close curly brace. Line 16: greater than sign. Line 17: greater than sign db dot art dot find open parenthesis close parenthesis dot sort open parenthesis open curly brace title colon 1 close curly brace close parenthesis. Note: Sorts on title field open parenthesis1 equals ascending close parenthesis. Line 18: dots. Line 19: greater than sign db dot art dot find open parenthesis open curly brace i d colon 400 close curly brace close parenthesis. Note: Searches for object with i d equals 400. Line 20: dots. Line 21: greater than sign db dot art dot find open parenthesis open curly brace i d colon open curly brace dollar gte colon 400 close curly brace close curly brace close parenthesis. Note: Searches for objects with i d greater than equals 400. Line 22: dots. Line 23: greater than sign db dot art dot find open parenthesis open curly brace title colon forward slash Night forward slash close curly brace close parenthesis. Note: Regular expression search. Line 24: dots. Line 25: greater than sign quit open parenthesis close parenthesis. Line 26: Line: tilde forward slash workspace dollar. Note: Imports JSON data file into funwebdev database in the collection books. Line 27: tilde forward slash workspace dollar mongoimport hyphen hyphen db funwebdev hyphen hyphen collection books hyphen hyphen file books. json hyphen hyphen jsonArray. Line 28: connected to colon 127 dot 0 dot 0 dot 1. Line 29: 2016 hyphen 08 hyphen 04T19 colon 12 colon 28. 053 plus 0000 check 9 215. Line 30: 2016 hyphen 08 hyphen 04T19 colon 12 colon 28. 053 plus 0000 imported 215 objects. Line 31: tilde forward slash workspace dollar.
Back