From MongoDB 4.4, you can use the $bsonSize aggregation pipeline operator to return the size of a given document in bytes.
$bsonSize accepts any valid expression as long as it resolves to either an object or null.
From MongoDB 4.4, you can use the $bsonSize aggregation pipeline operator to return the size of a given document in bytes.
$bsonSize accepts any valid expression as long as it resolves to either an object or null.
In MongoDB, you can use the Object.bsonSize() method to return the size of a document in bytes.
From MongoDB 4.4, you can use the $binarySize aggregation pipeline operator to return the size of a given string or binary data value’s content in bytes.
It accepts any valid expression as long as it resolves to either a string or binary data value. The argument can also be null, in which case, $binarySize returns null.
In MongoDB, you can use the $type element query operator to filter a collection of documents based on BSON type. It returns just those documents that have a particular BSON type in a specific field.
You provide the field and the BSON type, and $type will return all documents that match.
In MongoDB, the $type aggregation pipeline operator returns the BSON type of its argument.
You can use it to find out the type of a given field.
From MongoDB 4.0, you can use the $toObjectId aggregation pipeline operator to convert a string to an ObjectId.
The string must be a hexadecimal string of length 24.
In MongoDB, the $rtrim aggregation pipeline operator removes whitespace from the end of a string. This includes the null character.
It can also remove any character specified. For example, you could use it to remove all periods (.), exclamation marks (!), etc from the end of a string.
In MongoDB, the $ltrim aggregation pipeline operator removes whitespace from the beginning of a string. This includes the null character.
It can also remove any character specified. For example, you could use it to remove all hyphen characters (-) from the beginning of a string.
In MongoDB, the $trim aggregation pipeline operator removes whitespace from the beginning and end of a string. This includes the null character.
It can also remove any character specified. For example, you could use it to remove all hyphen characters (-) or periods (.) or all s characters, etc.
The following table contains a list of whitespace characters that MongoDB removes by default when using the $trim, $ltrim, and $rtrim aggregation pipeline operators.