Skip to content

Instantly share code, notes, and snippets.

@Mparaiso
Last active October 17, 2018 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mparaiso/2b639e3234a3265c4221e861fc735b2a to your computer and use it in GitHub Desktop.
Save Mparaiso/2b639e3234a3265c4221e861fc735b2a to your computer and use it in GitHub Desktop.
SQL to mongodb command cheat sheet: How to translate SQL into mongodb command?

SQL to Mongodb How to translate SQL into a Mongodb command?

SQL Mongodb
INSERT INTO collection(username,email,age) VALUES('johndoe','johndoe_at_example.com',28) db.collection.insert({username:'johndoe','johndoe_at_example.com'})
UPDATE collection SET username = 'jackdoe' WHERE email = 'johndoe_at_example.com'' db.collection.update({email:'johndoe_at_example.com''},{$set{username:'jackdoe'}})
SELECT COUNT(*) as count FROM collection WHERE age >= 18 db.collection.count({age:{$gte:18}}) or db.collection.aggregate([{$match:{age:{$gte:18}}},{$count:"count"}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment