In this lesson, we're going to talk about the different data types that MongoDB supports. And we're really going to get into some of the different data types that MongoDB has. But not only that, we're also going to talk about how we can query for documents by the data type that a field is. So by now, you already understand that MongoDB stores data in documents and you're already somewhat familiar with the different data types supported by MongoDB. For example, here I go ahead and query for a random movie and print it out. And as you can see, we know that title is a string. We know that runtime is a number. We've also looked at more complex data types in Mongo DB, like how cast is an array, or like how imdb is actually an embedded document. But let's look at all of the different data types that Mongo DB supports. And here is a list of all the different data types supported by Mongo DB on our documentation page. And we don't have time to talk about all these different data types, but in this lesson we're going to talk about three of the most interesting. So we're going to talk about ObjectId, Date, and finally we're going to talk about Decimal128. So coming back to our notebook, here is the random document that we found. We can go ahead and look at the specific _id field. And you'll notice that it has this ObjectId wrapper around this random string of letters and numbers. And so, this ObjectId is actually a MongoDB data type. And it's special because what it allows us to do is it allows MongoDB to identify, uniquely, every document in the database. And it's able to accomplish this because this random string of characters is actually composed of the current time in unix, the ID of the machine that is running this, the process ID, and as well as a counter that starts with a random value. And through all of these different pieces, MongoDB is able to, with somewhat good certainty, ensure that this ObjectId is unique. And is able to therefore uniquely identify every document in the database. And so that's ObjectId. Now let's talk about the Date data type. So I can go ahead and import datetime. And then I can go ahead and look at this example test collection that I've created called dates. So here's this dates database, and now I'm just going to go ahead and insert one document where I say dt, which is date time, is the current time right now. And so when I run this, you can see that it was successful and now I should be able to find it right away. And so, this is really cool. It's really awesome that MongoDB allows us to natively insert dates into MongoDB because this allows us to query for dates in a lot more interesting ways. We can now query for dates using logical operators like less than and greater than and a lot of other interesting things, like it allows us to use advanced aggregation operators that allow us to pull out different components of this date, like I can figure out the day of the year that this date is. Or I can figure out the year that this date is. And all this wouldn't be really possible if we were just storing this date as a simple string. And finally, I also want to talk about this really interesting data type called Decimal128. And so we already know that MongoDB allows us to store floating point numbers. But more than that, MongoDB also lets us store decimal numbers. And this is really important whenever you're storing numbers that represent something that has to be strictly precise and strictly represented. And a great example of this is money. So we don't want any rounding errors when you're doing math with money. And so when we are using money and storing it in MongoDB, we really want to use the Decimal128 data type so there's no rounding errors. And so MongoDB natively supports this. And so we can go ahead and import this special data type from the bson library. And then insert a document, pretty simple, the API is very simple. You just wrap your number as a string and then wrap that in the Decimal128 function. And then, as you can see, we've successfully inserted it. And now I can easily find it. And you can see that this is stored kind of exactly as the way we would expect. MongoDB is powerful, not only because it lets us store data with this rich variety of different data types, but also, it's really cool because we can actually query for documents based on their type. So in this case, you can see here, I'm writing a query where I want to find movies where the year is of type integer. And so when I run this, exactly as we would expect, here I'm able to find a movie where the year is an integer. And this is useful for two common-use cases. Firstly, this can be useful when we want to clean our data. We can use the $type operator to find that every field is the exact type that we expect it to be. But second, this can be very useful if we have a schema where a field has multiple data types across documents. For example, maybe we the director field as a string if a movie only has one director. But we store it as an array if it has multiple directors. In that case, we could use the $type operator to find movies of that specific type, whether it be string versus array, and go from there. So let's go ahead and recap what we discussed in this lesson. We saw a list of all the different data types in MongoDB and, specifically, we talked about three special ones. We talked about ObjectId, we talked about Date, and finally we talked about Decimal128. And then we saw that we can actually query MongoDB based on data type, which is useful for cleansing data. And it can also be useful when we have documents with different types for a field across multiple documents.