当前位置:网站首页>Document method
Document method
2022-07-05 20:16:00 【Why not sell egg cakes well】
18 Document Method
var stu=new StuModel({
name:" Rush to bully ",
age:48,
gender:"male"
});
console.log(stu);
stu.save(function (err){
if(!err){
console.log(" Saved successfully ");
}
});
StuModel.findOne({
},function (err,doc){
doc.update({
$set:{
age:27}},function (err){
if(!err){
console.log(" Modification successful ";)
}
})
});
StuModel.findOne({
},function (err,doc){
doc.age=18;
doc.save();
});
Delete
StuModel.findOne({
},function (err,doc){
doc.remove(function (err){
if(!err){
console.log(" Goodbye, elder martial brother ");
}
})
});
obtain
doc.get("age");
// Or more succinct
doc.age;
Set the specified attribute value of the document
doc.set("name","xai");
Database is not affected ,
doc.name="hhh";
Get document underline id
doc.id
toJson/toObject
Turn into json object , Pay attention to all document Object methods cannot be used
var j=doc.toJson();
Turn to object
doc=doc.toObject();
delete doc.address;
边栏推荐
- 基金网上开户安全吗?去哪里开,可以拿到低佣金?
- 图嵌入Graph embedding学习笔记
- DP:树DP
- A solution to PHP's inability to convert strings into JSON
- 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
- [C language] three implementations of quick sorting and optimization details
- C language OJ gets PE, OJ of ACM introduction~
- CADD课程学习(7)-- 模拟靶点和小分子相互作用 (半柔性对接 AutoDock)
- js方法传Long类型id值时会出现精确损失
- 1: Citation;
猜你喜欢
CTF逆向基础
Build your own website (16)
Unity editor extended UI control
leetcode刷题:二叉树10(完全二叉树的节点个数)
零道云新UI设计中
JVMRandom不可设置种子|问题追溯|源码追溯
Zero cloud new UI design
[quick start of Digital IC Verification] 7. Basic knowledge of digital circuits necessary for verification positions (including common interview questions)
死信队列入门(两个消费者,一个生产者)
Rainbond 5.7.1 支持对接多家公有云和集群异常报警
随机推荐
无卷积骨干网络:金字塔Transformer,提升目标检测/分割等任务精度(附源代码)...
期货如何网上开户?安不安全?
炒股开户最低佣金,低佣金开户去哪里手机上开户安全吗
July 4, 2022 - July 10, 2022 (UE4 video tutorial MySQL)
- Oui. Net Distributed Transaction and Landing Solution
【c语言】归并排序
model方法
Leetcode(347)——前 K 个高频元素
14. Users, groups, and permissions (14)
How to choose a good external disk platform, safe and formal?
Process file and directory names
Convolution free backbone network: Pyramid transformer to improve the accuracy of target detection / segmentation and other tasks (with source code)
股票开户哪里好?网上客户经理开户安全吗
Summer Challenge harmonyos - realize message notification function
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
Notes on key vocabulary in the English original of the biography of jobs (12) [chapter ten & eleven]
Reinforcement learning - learning notes 4 | actor critical
js方法传Long类型id值时会出现精确损失
BZOJ 3747 POI2015 Kinoman 段树
Bzoj 3747 poi2015 kinoman segment tree