MongoDB Tutorial - 6 - Data Types

Опубликовано: 03 Ноябрь 2024
на канале: JsWiz
2,678
18

In this video, we're going to discuss what types of data we can add to our database.

Full Course: http://jswiz.net

We've already introduced the concepts of what a Schema and a Collection are. You can think of them as essentially being equal - In so much as the Schema forms a representation or Model in code of the data that gets stored in our collection.

There are 6 main data types. String, Number, Date, Array, Boolean and ObjectId.

This graphic shows you what a typical key/value assignment is when working with each type of data. Then below, what a typical JSON response object would look like. String, Number and Date are pretty self-explanatory. When using an array, we can define it with the Array reserved word or with the brackets. Booleans can be set to either true or false. ObjectId refers to another collection or Schema. In a future example, I will show you how we can have a Book schema that References an Author Schema using the type ObjectId.