Databases, Collections, and Documents
In the section before, you connected to the database for this course.
Database-> Collections -> Documents
Each Database and Collection define a namespace.
🤓 Exploring Datasets in Compass
You will use the schema view Compass provides, that will show you a list of the fields, the data types, and a summary of the range of values for each field.
📌 Documents Scalar Value Types
Array, document, special value types (dates, maps)
A field can have multiple value types.
At compass, you can visualize the range of values. For dates, you can see them for days and hours.
📌 MongoDB Documents: Fields with Documents as Values
Using nested documents can help you model your database with a hierarchical data structure.
📌 MongoDb Documents: Fields with Arrays as Values
An array is a good choice when you need data that is a list.
📌 MongoDb Documents: Geospatial Data
There is a type called “Point” where you can store a variety of shapes, calculate the distance between points and filter documents with a specific radius.
🤓 Filtering Collections with Queries
At compass, if you click on a graph element, you’ll activate the filter functionality, and the filter element in the view will be updated.
JSON documents start and end with {}
JSON documents are composed of fields.
Fields have two parts: A key and a value.
The key is the name of the field.
The value is the value we want to filter with.
📌 Equality filter
📌 Range filter
$gte, greater than or equal to; $lt, less than
🤓 Understanding of JSON
JSON: Javascript Object Notation.
JSON object and JSON document are the same in MongoDB.
JSON objects are analogous to objects, structs, dictionaries in other programming languages.
📌 Rules:
All the keys have double quotes around them.
Keys and values must be separated by colons.
Fields are separated from one to another with commas.
JSON values can be strings, numbers, boolean, null, array, and objects.
Last updated
Was this helpful?