当前位置:网站首页>Model method
Model method
2022-07-05 20:17:00 【Why not sell egg cakes well】
17 Model Method
Model It's a constructor
Model.create(doc(s),[callback])
Create a document and add it to the database
Parameters doc(s) Can be a document object , It can also be an array .
callback Optional Callback function that is called when the operation is completed. .
// Inquire about
Model.find()
condition- Query criteria
projection Projection Fields to get
Two ways
{
name:1,_id:0}
"name age -_id"
option-- Query options skip limit
callback Callback function The callback function must pass , If not , Will not query .
// Always return an array
StuModel.find({
name:" Tang's monk "},function(err,docs){
if(!err){
console.log(docs);
}
}
);
StuModel.find({
},{
name:1,_id:0},function(err,docs){
if(!err){
//doc yes Document Document object , yes model Example .
console.log(docs);
}
}
);
StuModel.find({
},"name age -_id",function(err,docs){
if(!err){
console.log(doc instanceof StuModel);
}
}
);
modify
conditions Query criteria
doc Modified objects
options Configuration parameters
callback Callback function
StuModel.updateOne({
name:" Tang's monk "},{
$set:{
age:20}},function(err){
if(!err){
console.log(" Modification successful ");
}
});
Delete
StuModel.remove({
name:" Bones jing "},function(err){
if(!err){
console.log(" Delete successful ");
}
});
Statistical quantity Count
Model.count(conditions,[callback])
StuModel.count({},function(err,count){
if(!err){
console.log(count);
}
});
边栏推荐
- Mysql频繁操作出现锁表问题
- Leetcode skimming: binary tree 10 (number of nodes of a complete binary tree)
- Four methods of random number generation | random | math | threadlocalrandom | securityrandom
- When JS method passes long type ID value, precision loss will occur
- C langue OJ obtenir PE, ACM démarrer OJ
- CADD课程学习(7)-- 模拟靶点和小分子相互作用 (半柔性对接 AutoDock)
- 银河证券在网上开户安全吗?
- After 95, Alibaba P7 published the payroll: it's really fragrant to make up this
- 本季度干货导航 | 2022年Q2
- Rainbond 5.7.1 支持对接多家公有云和集群异常报警
猜你喜欢
Station B up builds the world's first pure red stone neural network, pornographic detection based on deep learning action recognition, Chen Tianqi's course progress of machine science compilation MLC,
Leetcode skimming: binary tree 10 (number of nodes of a complete binary tree)
【愚公系列】2022年7月 Go教学课程 004-Go代码注释
leetcode刷题:二叉树11(平衡二叉树)
无卷积骨干网络:金字塔Transformer,提升目标检测/分割等任务精度(附源代码)...
Convolution free backbone network: Pyramid transformer to improve the accuracy of target detection / segmentation and other tasks (with source code)
港股将迎“最牛十元店“,名创优品能借IPO突围?
Based on vs2017 and cmake GUI configuration, zxing and opencv are used in win10 x64 environment, and simple detection of data matrix code is realized
Mysql频繁操作出现锁表问题
Wechat applet regular expression extraction link
随机推荐
Zero cloud new UI design
MySql的root密码忘记该怎么找回
银河证券在网上开户安全吗?
model方法
leetcode刷题:二叉树12(二叉树的所有路径)
Autumn byte interviewer asked you any questions? In fact, you have stepped on thunder
leetcode刷题:二叉树10(完全二叉树的节点个数)
【数字IC验证快速入门】9、Verilog RTL设计必会的有限状态机(FSM)
2020 CCPC 威海 - A. Golden Spirit(思维),D. ABC Conjecture(大数分解 / 思维)
Scala basics [HelloWorld code parsing, variables and identifiers]
Practical demonstration: how can the production research team efficiently build the requirements workflow?
Debezium series: modify the source code to support UNIX_ timestamp() as DEFAULT value
ffplay文档[通俗易懂]
Jvmrandom cannot set seeds | problem tracing | source code tracing
基础篇——配置文件解析
Based on vs2017 and cmake GUI configuration, zxing and opencv are used in win10 x64 environment, and simple detection of data matrix code is realized
ROS2专题【01】:win10上安装ROS2
Leetcode skimming: binary tree 16 (path sum)
Bzoj 3747 poi2015 kinoman segment tree
Codeforces Round #804 (Div. 2) - A, B, C