-
Install local version https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/
-
Run the mongodb locally
mongod --config /usr/local/etc/mongod.conf
- Import both the json data into your local Mongodb instance
mongosh
show dbs;
use bggdb;
mongoimport -hlocalhost --port=27017 -dbggdb -cgame --jsonArray json/game.json
mongoimport -hlocalhost --port=27017 -dbggdb -ccomment --jsonArray json/comment.json
mongoimport --uri="mongodb://mongo:<password>@<mongohost>:<mongoport>/<mongodb>?authSource=admin" -dbggdb -cgame --jsonArray json/game.json
- Find all records
db.game.find()
- Find record witg predication
db.game.find( { "name": "Samurai" } )
- Drop mongo collection
db.game.drop()
- Get all record sort by field
db.game.find().sort("title")
- Get one record
db.game.find({"gid": 1})
- Create a searchable index and allow text query
db.game.createIndex({ "name": "text", "url": "text" });
db.game.find({ $text: { $search: "tic" } });
- Create Index for the Comment collection - Text Query
db.comment.createIndex({c_text: "text"})