MongoDB Basic cheats with mySQL equivalents

MongoDb mySQL Description
 show dbs SHOW DATABASES;  Print a list of databases
 use <db> USE <database name>;  Switch to named DB. In MongoDB this will also create a new database
show collections SHOW TABLES; Print a list of all collections / tables for current database
db.socks.find() SELECT  * FROM socks  Get all the documents/rows from the socks collection/table
db.socks.find( { _id: 10 } )  SELECT  * FROM socks WHERE id = 10;  Finds documents / rows with _id/id is equal to 10 (NB MongoDB _ID note below)
db.socks.find( { size: { $gt: 10, $lt: 14 } } ); SELECT * FROM socks WHERE size  > 10 AND size >14 Get all documents/rows where the size is greater than 10 and less than 14
db.socks.insertOne( { size:  8, qty: 15, colour:  red } ); INSERT INTO socks (‘size’, ‘qty’, ‘colour’) VALUES (8, 15, ‘red’);  Adds a new document/row to the collection/table

 

MongoDB _id :ObjectIds are small, likely unique, fast to generate, and ordered. ObjectId values consists of 12-bytes, where the first four bytes are a timestamp that reflect the ObjectId’s creation