Skip to content

Instantly share code, notes, and snippets.

Last active Oct 17, 2018
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','',28) db.collection.insert({username:'johndoe',''})
UPDATE collection SET username = 'jackdoe' WHERE email = ''' db.collection.update({email:'''},{$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