MySQL has a lot more data types than MongoDB, mainly because it supports more data types.
The first thing to understand is that all "data types" that are not a standard string or integer usually require wrappers or, rather, encapsulating objects.
A good example here is a date, in MySQL you have DATETIME , DATE , YEAR , TIMESTAMP , etc., whereas MongoDB just has ISODate() .
There is no direct translation table, but I will try to dig out the basics for you.
Note For some unknown reason, the MongoDB documentation actually produced a complete list of the data types available to you, so I had to look a bit for this list hidden in the glossary: http://docs.mongodb.org/manual/reference/glossary/#term- bson-types
The first thing you will notice when looking at this list is that there are many data types that do not exist in MySQL initially, for example, "Object" or "Array":
Binary sometimes called a BLOB in MySQL and is usually available through {d: new BinData($b)}ObjectId is MongoDB's special data type used by MongoDB for primary key types.String VARCHAR , TEXT , LONGTEXT and all those other types of strings combined in MySQL and are commonly used as {d: 'lalalaalala'} .Boolean commonly known as BOOL or TINYINT(1) in MySQL and is mainly used as: {d:true} .DATE is known as TIMESTAMP , DATE , DATETIME , YEAR and all these other types of dates in MySQL and is used as {d: new ISODate()}- A 32-bit integer is sometimes known as
TINYINT(11) , INTEGER , INT , SMALLINT , etc. in MYSQL and other small types of integer data and is used as {d:5} - A 64-bit integer is sometimes known as
MEDIUMINT and BIGINT in MySQL and is used as {d:new NumberLong("4")} NULL good NULL in MySQL and is used as {d:null}TIMESTAMP is not one that you will use publicly, so I will not talk about it, it is not what it seems.Double refers to DECIMAL and FLOAT in MySQL and can be used as {d:0.5} , however, due to its accuracy, I recommend storing your floats and double as integers.
And I believe that it covers the main ones that you need to know about.
Pretty little, so hope this helps.
source share