What We Will Cover Plug-ins Middleware Hooks Discriminators Promises Main Take-away – MongoDB is “schema-less” – Everything in Mongoose starts with a Schema Schema –
Tag: mongodb
MongoDb – Query for Array Element
db.Posts.insert({ PostBy: “Pankaj Choudhary”, Time:new Date(), Title:”MonogoDB Day2″, Tags:[ “NoSQL”, “MonogoDB”, “Database”, “SQL” ], Likes:3, Comment: [ { CommentBY : “Sanjeev”, Text: “Nice Show” },{
MongoDb – Tips
MongoDB Data Types Object This data type stores embedded documents. When a document contains another document in the form of key-value pair then such type
MonogDb – Index
Index Overview Index Creation Process B-Tree and how index works Default _id index with ObjectID getIndexes() Create new index – Which Fields should be added
MongoDB Aggregation 02
db.Persons.aggregate([ {$project: {isActive: 1, name:1, gender:1}} ]) //OUTPUT : { “_id” : ObjectId(“5f1f23e002c633f9f578dcde”), “name” : “Aurelia Gonzales”, “isActive” : false, “gender” : “female” } db.Persons.aggregate([
MongoDB Aggregation 01 – $match $group $Sort
db.Persons.aggregate([ //stage1 {$match: {tags: {$size: 3}}} ]) db.Persons.aggregate([ //stage1 {$match: {isActive: true}} ]) db.Persons.aggregate([ //stage1 {$match: {age: {$gt: 6}}} ]) $group : Example 1 db.Persons.aggregate([
MonogDB – Documents
MongoDB stores data records as BSON documents. BSON is a binary representation of JSON documents, though it contains more data types than JSON. BSON data
MongoDb – Update Queries
MongoDB Update Method The update method modifies the document(s) in a collection. Using the update method we can modify an entire document or a specific
MongoDb – Queries
Sample Document Git { “index”: NumberInt(0), “name”: “Aurelia Gonzales”, “isActive”: false, “registered”: ISODate(“2015-02-11T04:22:39+0000”), “age”: NumberInt(20), “gender”: “female”, “eyeColor”: “green”, “favoriteFruit”: “banana”, “company”: { “title”: “YURTURE”,
MongoDb Array Update Operators
2. $addToSet 3. $pop 4. $pull 5. $pullAll 6a. Positional Operator $ 6b. Positional Operator $ in Nested Docs 7.Positional Operator $ with $elemMatch 8.