Different Way Mongoose Connection

https://stackoverflow.com/questions/37695147/connect-mongo-creating-new-session-every-second var express = require(‘express’); var fs = require(‘fs’); var mongoose = require(‘mongoose’); var passport = require(‘passport’); var flash = require(‘connect-flash’); var morgan = require(‘morgan’);

CRUD Mongoose

CRUD Mongoose : https://zellwk.com/blog/mongoose/ Connecting to a database First, you need to download Mongoose. npm install mongoose –save You can connect to a database with

Mongoose Plugin

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 –

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([