Data types in MongoDB


Much data-types support to MongoDB whose list is given below:

String: The most commonly used data-type to store the data. String in MongoDB must be UTF-8 valid.
Integer:  Use to store a numerical value. Integer can be 32 bit or 64 bit depending upon your server.
Boolean: Use to store a Boolean (true/ false) value.
Double: Use to store floating-point values.
Symbol: This data-type is used identically to a string however, it's generally reserved for languages that use a specific symbol type.
Date: Use to store the current date or time in UNIX time format. You can specify your own date time by creating an object of Date and passing day, month, a year into it.
Object ID: Use to store the document’s ID.
Binary data: Use to store binary data.
Code: Use to store JavaScript code into the document.
Regular expression: Use to store regular expression
Min/ Max keys: This type is used to compare a value against the lowest and highest BSON elements.
Arrays: Use to store arrays or lists or multiple values into one key.
Timestamp: This can be handy for recording when a document has been modified or added.
Object: This data-type is used for embedded documents.
Null: This type is used to store a Null value.

Drop Collection in MongoDB




Syntax:
Db.collection-Name.drop();

Example:

>use mydb
switched to db mydb
>show collections
mycol
mycollection

Now drop collection by name,
>db.mycollection.drop()
true

Again check the list

>show collections
mycol

See the above result, mycollection is missing...

Related Posts

What is the Use of isNaN Function in JavaScript? A Comprehensive Explanation for Effective Input Validation

In the world of JavaScript, input validation is a critical aspect of ensuring that user-provided data is processed correctly. One indispensa...