Below is the MongoDB query statement that finds all documents where a == 2.
db.scores.find({a: 2});
Below MongoDB query statement that finds all documents where a > 15?
db.scores.find({a: {'$gt': 15}});
Below is the MongoDB query statement that finds all documents where a == 2.
db.scores.find({a: 2});
Below MongoDB query statement that finds all documents where a > 15?
db.scores.find({a: {'$gt': 15}});
Here's how you save a document to MongoDB:
db.scores.save({a: 99});
This command saves the document '{a: 99}' to the 'scores' collection. To query the document, we do
db.scores.find();
MongoDB is a document database. This means that we store data as documents, which are similar to JavaScript objects. Here below are a few sample JS objects:
var a = {age: 25}; var n = {name: 'Ed', languages: ['c', 'ruby', 'js']}; var student = {name: 'Jim', scores: [75, 99, 87.2]};