{"id":14956890,"url":"https://github.com/blaze-b/mongo-db-project-training","last_synced_at":"2026-02-12T18:31:07.365Z","repository":{"id":54998114,"uuid":"262804868","full_name":"blaze-b/mongo-db-project-training","owner":"blaze-b","description":"Basics about the mongo DB project, Reference Git URI:","archived":false,"fork":false,"pushed_at":"2021-01-16T16:54:03.000Z","size":45,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-04T05:53:38.239Z","etag":null,"topics":["json","mongo-db","sql"],"latest_commit_sha":null,"homepage":"git://githubcom/synedra/learning_mongo.git","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blaze-b.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-10T14:28:18.000Z","updated_at":"2021-01-16T16:54:34.000Z","dependencies_parsed_at":"2022-08-14T08:40:17.346Z","dependency_job_id":null,"html_url":"https://github.com/blaze-b/mongo-db-project-training","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/blaze-b/mongo-db-project-training","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaze-b%2Fmongo-db-project-training","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaze-b%2Fmongo-db-project-training/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaze-b%2Fmongo-db-project-training/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaze-b%2Fmongo-db-project-training/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blaze-b","download_url":"https://codeload.github.com/blaze-b/mongo-db-project-training/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaze-b%2Fmongo-db-project-training/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29376838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T18:17:34.915Z","status":"ssl_error","status_checked_at":"2026-02-12T18:17:34.495Z","response_time":55,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","mongo-db","sql"],"created_at":"2024-09-24T13:13:41.033Z","updated_at":"2026-02-12T18:31:07.350Z","avatar_url":"https://github.com/blaze-b.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mongo DB Training #\n\n- JSON Nested Json(Javascript Object Notation)\n- BSON is the format in mongoDB\n- Document structure is used\n- JavaScript Shell Commands\n- Excellent drivers\n\n\n## Document Structure\n\n- Documents = JSON Objects\n- Store data as BSON (Binary JSON)\n- Easy to access\n- Flexible indexing capability\n- Easy to adapt common coding practices\n\n## Embedded Data\n\n- Easier to work with\n- Minimizes coding operations\n- Easier to query and index\n\n## Include by reference\n\n- More operations for inserting and access\n- Aggregating data can be complex\n- Enables consitent data\n\n## [DB Reference](https://github.com/synedra/learning_mongo.git)\n\n\n## Json Basics\n\n- Types:\n  - String eg: \"Brian\"\n  - Numbers eg: 1,0,1.5,-30\n  - Boolean eg: true, false\n  - null eg: null\n  - Arrays eg: [1,2,3]\n  - Objects eg: {\"id\":\"1\",\"name\":\"Brian\"}\n\n\n## Big Data: \n- Three V's : Volume, Variety, Velocity(Veracity abnormailty in data )\n\n## Default Port of mongodb: 27017\n\n## Features of MONGO DB\n\n- No SQL \n- Horizontal Scalability\n- Indexing\n  1. It provides performance improvement\n  2. ADHOC queries are expensive\n  3. Large datasets can lose performance\n  4. Indices are even useful for very simple data\n  5. 64 indices per collection\n  6. Single field\n  7. Compound Indexing\n  8. Unique- `UUID`-\u003e Primary Key Equivalent and is unique for a document\n- Sharding \n  1. Shard key for identification similar to the partitioning\n  2. Partitions data onto different machines\n  3. Provides scalability via software\n  4. Autosharding\n  5. Challening in set up\n- Replication \n  1. Server in primary and secondary\n  2. Reliability\n  3. Maximizes uptime\n  4. Replica sets\n  5. Automatic failovers\n- Projection\n- Aggregation\n- Sorting\n- Limiting\n\n## Note\n\n- Cloud account creation atlas\n- Test Cluster use the read write options can be done\n- 4.2.6 version download as a zip \n- `Mongo db atlas` -\u003e cloud version\n- `Mongo stitch` -\u003e stitch.mongodb.com - apis is automatically created Backend as a service `BaaS`\n- `Mongo Compass` -\u003e official client similar to the robo mongo and better than the robo mongo\n- `Mongo Charts` -\u003e dynamic charts can be developed and is not a free version\n\n\n## Reference URL:\n- Reference: https://www.youtube.com/watch?v=iiADhChRriM (Please refer further as much as possible to gain expertise)\n- Reference: https://www.youtube.com/watch?v=uD3p_rZPBUQ (Please refer and as much as possible to gain expertise)\n- LinkedIn Course:  Learning Mongo DB – Kirsten Hunter (Please skip the node js section and exercise)\n- This will also include downloading Mongo db from software centre and setting it up in your machine and going through the exercises in it.\n\n\n## No SQL\n- Stands NOT ONLY SQl\n- A Non-Relational database(No tables)\n- A flexible database used for big data \u0026 real - time web apps\n- Multiple of No SQl databases\n- Document model and is more closely matches code objects, Designed for developers.\n\n## Big Data\n- Data sets that are large consist for 3 V's\n- Increase in the data volume\n- Challenges in storage, capture, analysis, transfer, etc\n\n## Advantages of NoSQL over RDBMS\n- Handled Big Data\n- Data Models - No predefined schema \u0026 Flexibility\n- Data Structure - NoSQL handles unstructured data\n- Cheaper to manage\n- Scaling- Scale out / Horizontal Scaling Scale-in \u0026 Scale-out\n- Scale-in stands for the vertical scaling \n- Scale-out it is cheaper nodes with the clustering and it is horizontal scaling\n- Table design is complex\n- Requires trained database administrators\n- Update requires wholesale operations\n- Complex queries to join related data\n- SQL writing\n- Table organization for dicrete data\n\n\n## Disadvantages \n- Better for relational data\n- Normalization\n- Well Known Language(SQL)\n- Data Integrity\n- ACID Compliance\n\n## Types of NO SQL Database\n- Document Databases[MongoDb,CouchDB]\n- Column Databases [ApacheCassandra]\n- Key-Value Store [Redis,CouchbaseServer]\n- Cache Systems [Redis,Memcache]\n- Graph Databases[Neo4j]\n\n## [Download Help Center](https://www.mongodb.com/download-center/community)\n\n- After the download copy the path 'C:\\Program Files\\MongoDB\\Server\\4.2\\bin' to the environment variable,\n- Create a directory in the C: folder data\\db\n\n## Simple Commands,\n- Start the server in cmd using `mongod` \n- Run the command `mongo` in another server\n- `mongod`, `mongo`, `mongoimport` Cmds for the local setup\n- `show dbs`\n- `use \u003c\u003cdbms_name\u003e\u003e`\n-  `show collections`\n- `db.\u003c\u003cdbms_name\u003e\u003e.find();`\n- `db.cars.insert({\"make\":\"Suzuki\"})`\n\n## Simple Exercise done in the mongo\n- `db.users.insert({\"name\":\"Brian\"})`\n- `show dbs`\n- `user test`\n- `show collections`\n- `db.users.find()`\n\n## TO FIND\n- `db.users.find(name: \"Brian\")`\n- `db.users.find(name: {$exists : true})`\n\n## TO REMOVE\n- `db.users.remove({name:\"Brian\"})`\n\n## TO UPDATE\n- `db.users.update({name:\"Brian\"}, {\"first_name\":\"Brian\", \"last_name\": \"Blaze\", \"location\":\"Kollam\"})`\n- `db.users.update({first_name:\"Brian\"}, {$set:{\"last_name\":\"Blaze\"}})`\n- `db.users.update({first_name:\"Brian\"}, {\"first_name\":\"Brian\", \"last_name\": \"Blaze\", \"location\":\"Kollam\", \"phone_number\":[9562315894,8917360248]})`\n- `db.users.find({phone_number:9562315894})`\n- `db.users.update({first_name:\"Brian\"}, {\"first_name\":\"Brian\", \"last_name\": \"Blaze\", \"location\":\"Kollam\", \"phone_number\": {\"type\":\"fax\",\"number\":\"9562315894\"}})`\n- `db.users.find({'phone_number.number': \"9562315894\"})`;\n\n\n## EXPLORE COMMANDs\n- `db`\n- `use learning_mongo` Output -\u003e switched to db learning_mongo\n- `show dbs` -\u003e The new db wont be shown unless a document is inserted\n- `show collections`\n- `print(\"Hello\")` -\u003e function to simply print details\n\n## Create variables in MONGO\n- `var arr = [1,2,3]`\n- `arr`\n- `for(i=0;i\u003c10;i++){\n... db.numbers.insert(\n... {numbers:i}\n... )\n... }`  -\u003e flexible java operations is posible in the mongo db\n- `db.numbers.count()`-\u003e Output 10\n- `db.numbers.find({numbers:1})` -\u003e Output { \"_id\" : ObjectId(\"5eb36cc7e08bb1a7f086e095\"), \"numbers\" : 1 }\n\n- `db.numbers.find({numbers:1}).explain()` -\u003e Output\n{\n        \"queryPlanner\" : {\n                \"plannerVersion\" : 1,\n                \"namespace\" : \"learning_mongo.numbers\",\n                \"indexFilterSet\" : false,\n                \"parsedQuery\" : {\n                        \"numbers\" : {\n                                \"$eq\" : 1\n                        }\n                },\n                \"queryHash\" : \"98425315\",\n                \"planCacheKey\" : \"98425315\",\n                \"winningPlan\" : {\n                        \"stage\" : \"COLLSCAN\",\n                        \"filter\" : {\n                                \"numbers\" : {\n                                        \"$eq\" : 1\n                                }\n                        },\n                        \"direction\" : \"forward\"\n                },\n                \"rejectedPlans\" : [ ]\n        },\n        \"serverInfo\" : {\n                \"host\" : \"LAPTOP-73B367G2\",\n                \"port\" : 27017,\n                \"version\" : \"4.2.6\",\n                \"gitVersion\" : \"20364840b8f1af16917e4c23c1b5f5efd8b352f8\"\n        },\n        \"ok\" : 1\n}\n- `db.numbers.find({numbers:1}).explain(\"executionStats\")` Output\n  {  \"executionStats\" : {\n                \"executionSuccess\" : true,\n                \"nReturned\" : 1,\n                \"executionTimeMillis\" : 0,\n                \"totalKeysExamined\" : 0,\n                \"totalDocsExamined\" : 10,\n                \"executionStages\" : {\n                        \"stage\" : \"COLLSCAN\",\n                        \"filter\" : {\n                                \"numbers\" : {\n                                        \"$eq\" : 1\n                                }\n                        },\n                        \"nReturned\" : 1,\n                        \"executionTimeMillisEstimate\" : 0,\n                        \"works\" : 12,\n                        \"advanced\" : 1,\n                        \"needTime\" : 10,\n                        \"needYield\" : 0,\n                        \"saveState\" : 0,\n                        \"restoreState\" : 0,\n                        \"isEOF\" : 1,\n                        \"direction\" : \"forward\",\n                        \"docsExamined\" : 10\n                }\n        },\n        \"serverInfo\" : {\n                \"host\" : \"LAPTOP-73B367G2\",\n                \"port\" : 27017,\n                \"version\" : \"4.2.6\",\n                \"gitVersion\" : \"20364840b8f1af16917e4c23c1b5f5efd8b352f8\"\n        },\n        \"ok\" : 1\n}\n- `db.numbers.createIndex({number:1})` Output\n{\n        \"createdCollectionAutomatically\" : false,\n        \"numIndexesBefore\" : 1,\n        \"numIndexesAfter\" : 2,\n        \"ok\" : 1\n}\n\n## Importing a file\n\n- `mongoimport --help`\nnamespace options:\n  /d, /db:\u003cdatabase-name\u003e                         database to use\n  /c, /collection:\u003ccollection-name\u003e               collection to usesss\n\ninput options:\n  /f, /fields:\u003cfield\u003e[,\u003cfield\u003e]*                  comma separated list of fields, e.g. -f name,age\n      /fieldFile:\u003cfilename\u003e                       file with field names - 1 per line\n      /file:\u003cfilename\u003e                            file to import from; if not specified, stdin is used\n      /headerline                                 use first line in input source as the field list (CSV\n                                                  and TSV only)\n      /jsonArray                                  treat input source as a JSON array\n      /parseGrace:\u003cgrace\u003e                         controls behavior when type coercion fails - one of: autoCast, skipField, skipRow, stop (defaults to 'stop') (default: stop)\n      /type:\u003ctype\u003e                                input format to import: json, csv, or tsv (defaults to 'json') (default: json)\n      /columnsHaveTypes                           indicated that the field list (from --fields, --fieldsFile, or --headerline) specifies types; They must be in the form of\n                                                  '\u003ccolName\u003e.\u003ctype\u003e(\u003carg\u003e)'. The type can be one of: auto, binary, bool, date, date_go, date_ms, date_oracle, double,\n                                                  int32, int64, string. For each of the date types, the argument is a datetime layout string. For the binary type, the argument can be one of: base32, base64, hex. All other types take an empty argument. Only valid for CSV and TSV imports. e.g. zipcode.string(), thumbnail.binary(base64)\n      /legacy                                     use the legacy extended JSON format (defaults to 'false') (default: false)\n\n- change directory to the json file path\n- `mongoimport /db:learning_mongo /collection:tours /jsonArray /file:tours.json` -\u003e Output\n2020-05-07T08:22:43.053+0530    connected to: mongodb://localhost/\n2020-05-07T08:22:43.187+0530    29 document(s) imported successfully. 0 document(s) failed to import.\n\n## Commands after importing\n\n- `show dbs`\n- `show collections`\n- `db.tours.find()`\n- `db.tours.find({toursTags:\"hiking\"})`\n- `db.tours.find({toursTags:\"wine\"})`\n- `db.tours.insert({\n... \"tourName\": \"The Wines of Santa Cruz\",\n... \"tourLength\": 3,\n... \"tourDescription\": \"Discover Santa Cruz's wineries\",\n... \"tourPrice\": 500,\n... \"tourTags\":[\"wine\",\"Santa Cruz\"],\n... }\n... )`\n- `db.tours.count()`\n\n## Add a new entry\n\n- `db.tours.update({tourName: \"The Wines of Santa Cruz\"},{$set:{\"tourRegion\":\"Central Coast\"}})`\n\n## Add a new entry in an array\n\n- `db.tours.update({tourName:\"The Wines of Santa Cruz\"}, {$addToSet: {\"tourTags\":\"boardwalk\"}})`\n\n- `db.tours.remove({\"tourName\" : \"The Wines of Santa Cruz\"})`\n\n- `db.tours.drop()` -\u003e drops a collection\n\n## Indexing\n\n- Run the mongo import command on the tours.json file\n- `db.tours.find({tourPackage :\"Taste of California\"}).explain(\"executionStats\")` Output {\"totalDocsExamined\" : 29,} -\u003e All the documents where examined\n- `db.tours.createIndex({tourPackage:1})` -\u003e Index the search id\n- `db.tours.find({tourPackage :\"Taste of California\"}).explain(\"executionStats\")` Run again Output shows {\"totalDocsExamined\" : 4,} only 4 where scanned\n\n- Mutiple Indexing\n  - Querying will make it efficient searching\n  - Searching based on less than or equal to \n  - `db.tours.find({tourPrice:{$lte:500}, tourLength:{$lte:3}})`\n  - `db.tours.createIndex({tourPrice:1,tourLength:1})`\n  - `db.tours.find({tourPrice:{$lte:500}, tourLength:{$lte:3}}).explain(\"executionStats\")` Run again Output shows {\"totalDocsExamined\" : 10,} only 4 where scanned\n\n\n## Finding any string values equivalent to the like operation in SQL\n\n- `db.profiles.find({'profile.name': {'$regex': /b/i}})` //like '%a%'\n- `db.profiles.find({'profile.name': {'$regex': /^b/i}})` //like 'pa%' \n- `db.profiles.find({'profile.name': {'$regex': /b$/i}})` //like '%ro'\n\n## Query to display particular fields\n\n- `db.collection_name.find( { \"Search_Field\": \"value\" }, { \"Field_to_display\": 1,_id:0 })`\n   eg:`db.profiles.find({hobbies:{$regex:/^d/i}},{'profile.name':1, hobbies: 1,_id:0})`\n   OUTPUT-\u003e\n   { \"profile\" : { \"name\" : \"Manhu Varghese\" }, \"hobbies\" : [ \"Reading\", \"Drawing\" ] }\n   { \"profile\" : { \"name\" : \"Jaisha Raveendran\" }, \"hobbies\" : [ \"Origami\", \"Drawing\" ] }\n   { \"profile\" : { \"name\" : \"Manu M\" }, \"hobbies\" : [ \"Reading\", \"Drawing\" ] }\n   { \"profile\" : { \"name\" : \"Dhanya S\" }, \"hobbies\" : [ \"Reading\", \"Drawing\" ] }\n   { \"profile\" : { \"name\" : \"Brian Blaze\" }, \"hobbies\" : [ \"Reading\", \"Drawing\" ] }\n   { \"profile\" : { \"name\" : \"Devika M\" }, \"hobbies\" : [ \"Reading\", \"Drawing\" ] }\n\n## [Exercise 1](https://github.com/brianblaze14/mongo-db-project/blob/master/exercise/mongodb-exercis.md)\n\n\n## HAPI Server Setup connection to the Mongo DB\n\n- Install http-server by using command `npm install -g http-server` (add C:\\Users\\username\\AppData\\Roaming\\npm and C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\http-server to environment variable 'PATH')\n- Install httpie for `http` command to work -\u003e [reference URL](https://www.logicbig.com/how-to/tools/install-httpie.html)\n- API Testing:\n  - Test URI based on the key search -\u003e http://localhost:8081/api/tours?tourPackage=Backpack%20Cal\n  - Test URI for path variable -\u003e http://localhost:8081/api/tours/Big%20Sur%20Retreat\n  - Test URI for Posting -\u003e http POST http://localhost:8081/api/tours tourName=\"Kerala Days\" tourPackage=\"Fun in Sun\" tourPrice=10000 tourLength=5 to check whether it is inserted http \"http://localhost:8081/api/tours/Kerala Days\"\n  - Test URI for put : http PUT \"http://localhost:8081/api/tours/Kerala Days\" tourBlurb=\"Get your tan on\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaze-b%2Fmongo-db-project-training","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblaze-b%2Fmongo-db-project-training","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaze-b%2Fmongo-db-project-training/lists"}