HTML, CSS, and JavaScript: These form the fundamental building blocks of web development. HTML structures the content, CSS styles it, and JavaScript adds interactivity. Together, they create dynamic and engaging web experiences.
Python: A versatile language suitable for web development, data...
Disclaimer
GoalKicker.com This is an unocial free book created for educational purposes and is
not aliated with ocial MongoDB® group(s) or company(s).
Free Programming Books All trademarks and registered trademarks are
the property of their respective owners
,Contents
About ................................................................................................................................................................................... 1
Chapter 1: Getting started with MongoDB ....................................................................................................... 2
Section 1.1: Execution of a JavaScript file in MongoDB ............................................................................................. 2
Section 1.2: Making the output of find readable in shell ............................................................................................ 2
Section 1.3: Complementary Terms ............................................................................................................................. 3
Section 1.4: Installation .................................................................................................................................................. 3
Section 1.5: Basic commands on mongo shell ............................................................................................................ 6
Section 1.6: Hello World ................................................................................................................................................. 6
Chapter 2: CRUD Operation ..................................................................................................................................... 7
Section 2.1: Create ......................................................................................................................................................... 7
Section 2.2: Update ....................................................................................................................................................... 7
Section 2.3: Delete ......................................................................................................................................................... 8
Section 2.4: Read ........................................................................................................................................................... 8
Section 2.5: Update of embedded documents .......................................................................................................... 9
Section 2.6: More update operators .......................................................................................................................... 10
Section 2.7: "multi" Parameter while updating multiple documents ...................................................................... 10
Chapter 3: Getting database information ..................................................................................................... 11
Section 3.1: List all collections in database ............................................................................................................... 11
Section 3.2: List all databases .................................................................................................................................... 11
Chapter 4: Querying for Data (Getting Started) ....................................................................................... 12
Section 4.1: Find() ......................................................................................................................................................... 12
Section 4.2: FindOne() ................................................................................................................................................. 12
Section 4.3: limit, skip, sort and count the results of the find() method ................................................................ 12
Section 4.4: Query Document - Using AND, OR and IN Conditions ....................................................................... 14
Section 4.5: find() method with Projection ................................................................................................................ 16
Section 4.6: Find() method with Projection ............................................................................................................... 16
Chapter 5: Update Operators .............................................................................................................................. 18
Section 5.1: $set operator to update specified field(s) in document(s) ................................................................. 18
Chapter 6: Upserts and Inserts ............................................................................................................................ 20
Section 6.1: Insert a document ................................................................................................................................... 20
Chapter 7: Collections .............................................................................................................................................. 21
Section 7.1: Create a Collection .................................................................................................................................. 21
Section 7.2: Drop Collection ....................................................................................................................................... 22
Chapter 8: Aggregation ........................................................................................................................................... 23
Section 8.1: Count ........................................................................................................................................................ 23
Section 8.2: Sum .......................................................................................................................................................... 23
Section 8.3: Average ................................................................................................................................................... 24
Section 8.4: Operations with arrays .......................................................................................................................... 25
Section 8.5: Aggregate query examples useful for work and learning ................................................................. 25
Section 8.6: Match ....................................................................................................................................................... 29
Section 8.7: Get sample data ..................................................................................................................................... 30
Section 8.8: Remove docs that have a duplicate field in a collection (dedupe) .................................................. 30
Section 8.9: Left Outer Join with aggregation ( $Lookup) ..................................................................................... 30
Section 8.10: Server Aggregation .............................................................................................................................. 31
Section 8.11: Aggregation in a Server Method .......................................................................................................... 31
Section 8.12: Java and Spring example .................................................................................................................... 32
,Chapter 9: Indexes ...................................................................................................................................................... 34
Section 9.1: Index Creation Basics .............................................................................................................................. 34
Section 9.2: Dropping/Deleting an Index .................................................................................................................. 36
Section 9.3: Sparse indexes and Partial indexes ...................................................................................................... 36
Section 9.4: Get Indices of a Collection ..................................................................................................................... 37
Section 9.5: Compound ............................................................................................................................................... 38
Section 9.6: Unique Index ........................................................................................................................................... 38
Section 9.7: Single field ............................................................................................................................................... 38
Section 9.8: Delete ....................................................................................................................................................... 38
Section 9.9: List ............................................................................................................................................................ 39
Chapter 10: Bulk Operations ................................................................................................................................. 40
Section 10.1: Converting a field to another type and updating the entire collection in Bulk ............................... 40
Chapter 11: 2dsphere Index .................................................................................................................................... 43
Section 11.1: Create a 2dsphere Index ........................................................................................................................ 43
Chapter 12: Pluggable Storage Engines .......................................................................................................... 44
Section 12.1: WiredTiger .............................................................................................................................................. 44
Section 12.2: MMAP ...................................................................................................................................................... 44
Section 12.3: In-memory ............................................................................................................................................. 44
Section 12.4: mongo-rocks ......................................................................................................................................... 44
Section 12.5: Fusion-io ................................................................................................................................................. 44
Section 12.6: TokuMX ................................................................................................................................................... 45
Chapter 13: Java Driver ........................................................................................................................................... 46
Section 13.1: Fetch Collection data with condition .................................................................................................... 46
Section 13.2: Create a database user ........................................................................................................................ 46
Section 13.3: Create a tailable cursor ........................................................................................................................ 46
Chapter 14: Python Driver ...................................................................................................................................... 48
Section 14.1: Connect to MongoDB using pymongo ................................................................................................ 48
Section 14.2: PyMongo queries .................................................................................................................................. 48
Section 14.3: Update all documents in a collection using PyMongo ...................................................................... 49
Chapter 15: Mongo as Shards ............................................................................................................................... 50
Section 15.1: Sharding Environment Setup ................................................................................................................ 50
Chapter 16: Replication ............................................................................................................................................ 51
Section 16.1: Basic configuration with three nodes .................................................................................................. 51
Chapter 17: Mongo as a Replica Set ................................................................................................................. 53
Section 17.1: Mongodb as a Replica Set .................................................................................................................... 53
Section 17.2: Check MongoDB Replica Set states .................................................................................................... 54
Chapter 18: MongoDB - Configure a ReplicaSet to support TLS/SSL ............................................. 56
Section 18.1: How to configure a ReplicaSet to support TLS/SSL? ......................................................................... 56
Section 18.2: How to connect your Client (Mongo Shell) to a ReplicaSet? ............................................................ 58
Chapter 19: Authentication Mechanisms in MongoDB .............................................................................. 60
Section 19.1: Authentication Mechanisms .................................................................................................................. 60
Chapter 20: MongoDB Authorization Model ................................................................................................. 61
Section 20.1: Build-in Roles ......................................................................................................................................... 61
Chapter 21: Configuration ...................................................................................................................................... 62
Section 21.1: Starting mongo with a specific config file ........................................................................................... 63
Chapter 22: Backing up and Restoring Data ................................................................................................ 64
Section 22.1: Basic mongodump of local default mongod instance ...................................................................... 64
Section 22.2: Basic mongorestore of local default mongod dump ....................................................................... 64
, Section 22.3: mongoimport with JSON ..................................................................................................................... 64
Section 22.4: mongoimport with CSV ........................................................................................................................ 65
Chapter 23: Upgrading MongoDB version ..................................................................................................... 66
Section 23.1: Upgrading to 3.4 on Ubuntu 16.04 using apt ...................................................................................... 66
Credits .............................................................................................................................................................................. 67
You may also like ........................................................................................................................................................ 69
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller yashpatel5. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $7.99. You're not tied to anything after your purchase.