当前位置:网站首页>document方法
document方法
2022-07-05 20:12:00 【为什么不好好卖蛋饼】
18 Document方法
var stu=new StuModel({
name:"奔波霸",
age:48,
gender:"male"
});
console.log(stu);
stu.save(function (err){
if(!err){
console.log("保存成功");
}
});
StuModel.findOne({
},function (err,doc){
doc.update({
$set:{
age:27}},function (err){
if(!err){
console.log("修改成功";)
}
})
});
StuModel.findOne({
},function (err,doc){
doc.age=18;
doc.save();
});
删除
StuModel.findOne({
},function (err,doc){
doc.remove(function (err){
if(!err){
console.log("大师兄再见");
}
})
});
获取
doc.get("age");
//或者更简洁
doc.age;
设置文档指定属性值
doc.set("name","xai");
数据库没影响,
doc.name="hhh";
获取文档下划线id
doc.id
toJson/toObject
转成json对象,注意所有的document对象的方法都不能使用
var j=doc.toJson();
转成对象
doc=doc.toObject();
delete doc.address;
边栏推荐
- How to retrieve the root password of MySQL if you forget it
- [quick start of Digital IC Verification] 7. Basic knowledge of digital circuits necessary for verification positions (including common interview questions)
- Debezium series: PostgreSQL loads the correct last submission LSN from the offset
- Notes on key vocabulary in the English original of the biography of jobs (12) [chapter ten & eleven]
- 14. Users, groups, and permissions (14)
- 【数字IC验证快速入门】7、验证岗位中必备的数字电路基础知识(含常见面试题)
- The difference between ID selector and class selector
- Debezium series: record the messages parsed by debezium and the solutions after the MariaDB database deletes multiple temporary tables
- .Net分布式事务及落地解决方案
- SecureRandom那些事|真伪随机数
猜你喜欢

leetcode刷题:二叉树13(相同的树)

Rainbond 5.7.1 支持对接多家公有云和集群异常报警

Leetcode: binary tree 15 (find the value in the lower left corner of the tree)

Let's talk about threadlocalinsecurerandom
Android interview classic, 2022 Android interview written examination summary

微信小程序正则表达式提取链接

Leetcode brush questions: binary tree 11 (balanced binary tree)

Parler de threadlocal insecurerandom

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

95后阿里P7晒出工资单:狠补了这个,真香...
随机推荐
Wildcard selector
Leetcode: binary tree 15 (find the value in the lower left corner of the tree)
【c语言】快速排序的三种实现以及优化细节
字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验
Autumn byte interviewer asked you any questions? In fact, you have stepped on thunder
什么是pyc文件
信息学奥赛一本通 1337:【例3-2】单词查找树 | 洛谷 P5755 [NOI2000] 单词查找树
ffplay文档[通俗易懂]
ACM getting started Day1
【数字IC验证快速入门】8、数字IC中的典型电路及其对应的Verilog描述方法
.Net分布式事务及落地解决方案
港股将迎“最牛十元店“,名创优品能借IPO突围?
淺淺的談一下ThreadLocalInsecureRandom
Scala基础【HelloWorld代码解析,变量和标识符】
leetcode刷题:二叉树12(二叉树的所有路径)
sun.misc.BASE64Encoder报错解决方法[通俗易懂]
leetcode刷题:二叉树11(平衡二叉树)
Go language | 02 for loop and the use of common functions
Leetcode skimming: binary tree 12 (all paths of binary tree)
Build your own website (16)