Tutorial by Examples

To install MongoDB, follow the steps below: For Mac OS: There are two options for Mac OS: manual install or homebrew. Installing with homebrew: Type the following command into the terminal: $ brew install mongodb Installing manually: Download the latest release here. Ma...
After installation process, the following lines should be entered in mongo shell (client terminal). > db.world.insert({ "speech" : "Hello World!" }); > cur = db.world.find();x=cur.next();print(x["speech"]); Hello World! Explanation: In the first line,...
SQL TermsMongoDB TermsDatabaseDatabaseTableCollectionEntity / RowDocumentColumnKey / FieldTable JoinEmbedded DocumentsPrimary KeyPrimary Key (Default key _id provided by mongodb itself)
./mongo localhost:27017/mydb myjsfile.js Explanation: This operation executes the myjsfile.js script in a mongo shell that connects to the mydb database on the mongod instance accessible via the localhost interface on port 27017. localhost:27017 is not mandatory as this is the default port mongo...
We add three records to our collection test as: > db.test.insert({"key":"value1","key2":"Val2","key3":"val3"}) WriteResult({ "nInserted" : 1 }) > db.test.insert({"key":"value2","key2":"V...
Show all available databases: show dbs; Select a particular database to access, e.g. mydb. This will create mydb if it does not already exist: use mydb; Show all collections in the database (be sure to select one first, see above): show collections; Show all functions that can be used w...

Page 1 of 1