当前位置:网站首页>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);
}
});
边栏推荐
- Scala基础【HelloWorld代码解析,变量和标识符】
- js实现禁止网页缩放(Ctrl+鼠标、+、-缩放有效亲测)
- Minimum commission for stock trading account opening, where to open an account with low commission? Is it safe to open an account on your mobile phone
- Zero cloud new UI design
- 1:引文;
- C langue OJ obtenir PE, ACM démarrer OJ
- 怎么挑选好的外盘平台,安全正规的?
- 《乔布斯传》英文原著重点词汇笔记(十二)【 chapter ten & eleven】
- Unity editor extended UI control
- After 95, Alibaba P7 published the payroll: it's really fragrant to make up this
猜你喜欢
![[quick start of Digital IC Verification] 6. Quick start of questasim (taking the design and verification of full adder as an example)](/img/6d/110b87747f0a4be52da9fd49a05b82.png)
[quick start of Digital IC Verification] 6. Quick start of questasim (taking the design and verification of full adder as an example)

淺淺的談一下ThreadLocalInsecureRandom

【数字IC验证快速入门】3、数字IC设计全流程介绍

CADD课程学习(7)-- 模拟靶点和小分子相互作用 (半柔性对接 AutoDock)

.Net分布式事務及落地解决方案

After 95, Alibaba P7 published the payroll: it's really fragrant to make up this

Mysql频繁操作出现锁表问题

港股将迎“最牛十元店“,名创优品能借IPO突围?

Leetcode brush question: binary tree 13 (the same tree)

基础篇——配置文件解析
随机推荐
[quick start to digital IC Verification] 8. Typical circuits in digital ICs and their corresponding Verilog description methods
基金网上开户安全吗?去哪里开,可以拿到低佣金?
Schema和Model
点云文件的.dat文件读取保存
14. Users, groups, and permissions (14)
关于BRAM IP复位的优先级
期货如何网上开户?安不安全?
计算lnx的一种方式
July 4, 2022 - July 10, 2022 (UE4 video tutorial MySQL)
Go language | 01 wsl+vscode environment construction pit avoidance Guide
PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
解决php无法将string转换为json的办法
2022年7月4日-2022年7月10日(ue4视频教程mysql)
【数字IC验证快速入门】8、数字IC中的典型电路及其对应的Verilog描述方法
零道云新UI设计中
死信队列入门(两个消费者,一个生产者)
y57.第三章 Kubernetes从入门到精通 -- 业务镜像版本升级及回滚(三十)
什么是pyc文件
MySql的root密码忘记该怎么找回
基础篇——配置文件解析