diff options
Diffstat (limited to 'mongodb.html.markdown')
| -rw-r--r-- | mongodb.html.markdown | 23 | 
1 files changed, 12 insertions, 11 deletions
| diff --git a/mongodb.html.markdown b/mongodb.html.markdown index 959b57d0..f4e7d709 100644 --- a/mongodb.html.markdown +++ b/mongodb.html.markdown @@ -228,7 +228,7 @@ db.engineers.update({ name: 'Foo Baz' },  )  /////////////////////// Delete ///////////////////////// -// Queries are in the form of db.collectionName.find(<filter>) +// Queries are in the form of db.collectionName.delete(<filter>)  // Delete first document matching query, always returns deletedCount  db.engineers.deleteOne({ name: 'Foo Baz' }) @@ -252,20 +252,21 @@ db.engineers.deleteMany({ gender: 'Male' })  //////////////// Comparison Operators ///////////////////  // Find all greater than or greater than equal to some condition -db.engineers.find({ $gt: { age: 25 }}) -db.engineers.find({ $gte: { age: 25 }}) +db.engineers.find({ age: { $gt: 25 }}) +db.engineers.find({ age: { $gte: 25 }})  // Find all less than or less than equal to some condition -db.engineers.find({ $lte: { age: 25 }}) -db.engineers.find({ $lte: { age: 25 }}) +db.engineers.find({ age: { $lt: 25 }}) +db.engineers.find({ age: { $lte: 25 }})  // Find all equal or not equal to  // Note: the $eq operator is added implicitly in most queries -db.engineers.find({ $eq: { age: 25 }}) -db.engineers.find({ $ne: { age: 25 }}) +db.engineers.find({ age: { $eq: 25 }}) +db.engineers.find({ age: { $ne: 25 }}) -// Find all that match any element in the array -db.engineers.find({ age: ${ in: [ 20, 23, 24, 25 ]}}) +// Find all that match any element in the array, or not in the array +db.engineers.find({ age: { $in: [ 20, 23, 24, 25 ]}}) +db.engineers.find({ age: { $nin: [ 20, 23, 24, 25 ]}})  //////////////// Logical Operators /////////////////// @@ -293,7 +294,7 @@ db.engineers.find({ $not: {  // Must match none of the query conditions  db.engineers.find({ $nor [ -  gender: 'Female, +  gender: 'Female',    age: {      $gte: 18    } @@ -400,6 +401,6 @@ features, I would look at  - Aggregation - useful for creating advanced queries to be executed by the    database -- Idexing allows for caching, which allows for much faster execution of queries +- Indexing allows for caching, which allows for much faster execution of queries  - Sharding allows for horizontal data scaling and distribution between multiple    machines. | 
