Please enable JavaScript.
Coggle requires JavaScript to display documents.
MONGOOSE_1 - Coggle Diagram
MONGOOSE_1
QUERYING
SingleData
User.findById(..)
SimilarTo
MongoDb
List
.find({k:v})
GetOne
.findOne({k:v})
Exists
.exists({k:v})
.deleteOne({k:v})
Where
Chaining
User.where("name")
.equals("val")
.where("age")
.gt(12)
.lt(21)
.limit(2)
Selecting
.select("age")
ObjId
Change
ref
Required
In-Schema
user
.bestFriend = someId
.save()
Populate
Equivalent
To-Join
In-Sql
Using
.populate("bestFriend")
.where
AddFields
Of-Referenced
Data
INSTALL
npm i mongoose
Env-Vars
DATABASE_URL
Using
In-Server.js
const mongoose =
require("mongoose")
mongoose.connect(..)
process.env.DB_URL
[connectFunc]
[errorFunc]
On-Error
db.on(..)
'error'
(er) => clo(er)
const db =
mongoose.connection
On-Success
'open'
() => clo("Connected")
db.once(..)
REST
Client
Extension
VSCode
SCHEMA
Methods
Virtuals
USING
Model
MIDDLEWARE