

It is the language-independent format of data interchange. BSON is supported a more advanced datatype as compared to JSON in MongoDB. We cannot read the BSON data, it is not in human-readable format, the only machines can read the BSON type of data.Įncoding of BSON type format in MongoDB is binary. The last line indicates the end of the object. Fourth line is indicates that field value for the field name which was we have used in our documents. Third line is indicates that field name which was we have used in our documents. Second-line indicates that string type that we have used to store the document. The below format shows how the BSON document is stored in the database.įirst-line indicates the size of the document which was required to store the document.

The below example shows the how BSON document is stored in the database. We can use the above datatype in our collection field using BSON datatype in MongoDB. Type operator is supported values to query the fields while using BSON datatype in MongoDB. The BSON records are small as compared to the JSON records in MongoDB. It is a binary format type that was used in MongoDB to store the data in binary format. BSON in MongoDB stands for Binary JavaScript Object Notation whereas JSON stands for JavaScript Object Notation. BSON is advanced of JSON in MongoDB, there are multiple advanced datatypes used in BSON.īelow is the datatype of BSON which was available in MongoDB. Mongoimport command is used for importing the data into the collection by using BSON format file. We can specify any name to the BSON file.Ĩ) Mongoimport – This is used to import the BSON file data into the collection or database which was we have defined in our command. We need to specify dbname while exporting data into BSON file format.Ħ) Out – This parameter is the default which was we need to use at the time of exporting any collection in MongoDB.ħ) Filename – This is defined as the name of BSON dump file. Mongoexport command is used for exporting the data of collection or databases into the BSON format file.Ĥ) Collection – This parameter is used to export the specified collection into the MongoDB BSON file.ĥ) DB – This parameter is used to export the specified database collection into the MongoDB BSON file. We can export any database or collection in BSON file format. We can use multiple fields in a single collection and also give different datatype to different fields.Ģ) Value1 to ValueN – This is the value which was we have assigned for the BSON documents field.ģ) Mongoexport – This parameter is used to export the collection documents of the database into the BSON file. Mongoimport –collection = collection_name –db = db_name –username -password –file filename.bsonġ) Field 1 to field N – This contains the field which was we have used while inserting the documents into the collection by using BSON data types.
