Skip to content

Instantly share code, notes, and snippets.

@Mparaiso

Mparaiso/sql_to_mongodb.md

Last active Oct 17, 2018
Embed
What would you like to do?
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