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"}]) |