Please enable JavaScript.
Coggle requires JavaScript to display documents.
MONGOOSE_3 SCHEMA - Coggle Diagram
MONGOOSE_3
SCHEMA
INSTANCE
Methods
userSchema
.methods
.newMethod =
function () {..}
const userName
= this.name
clo("Name is : " + userName)
QUERY
Methods
Available
OnlyOn
QueryResult
e.g-find
userSchema
.query
.byName =
function (name) {..}
Return
this.where(..)
STATIC
Methods
Available
Only-On
Static
NotOn
QueryResult
userSchema
.statics
.findByName =
function(nm) {..}
Return
this.where({..})
name:
new RegExp(nm, 'i')
MIDDLEWARE
UseFor
save
validate
remove
updateOne
userSchema
.pre/post
before/after
Main-Operation
pre(..)
'save'
function(next) {..}
this.updatedAt =
Date.now()
next()
next()
Is-next
middleware
function
post(..)
'save'
function(doc, next) {..}
doc
Is-ModelObj
Equivalent
To-This
In-Pre
ARROW
Function
Cannot
Be-Used
This
Keyword
Is-Used
VIRTUAL
Property
Virtual
SimilarTo
Annotation
In-Sql
userSchema
.virtual('namedEmail')
.get(funcGet)
.set(funcSet)
funcGet :
function() {..}
return
"this.name ->
this.email"