当前位置:网站首页>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;
边栏推荐
- Securerandom things | true and false random numbers
- 【数字IC验证快速入门】1、浅谈数字IC验证,了解专栏内容,明确学习目标
- How to select the Block Editor? Impression notes verse, notation, flowus
- 国信证券在网上开户安全吗?
- 计算lnx的一种方式
- Android interview classic, 2022 Android interview written examination summary
- 秋招字节面试官问你还有什么问题?其实你已经踩雷了
- sun.misc.BASE64Encoder报错解决方法[通俗易懂]
- kubernetes资源对象介绍及常用命令(五)-(ConfigMap&Secret)
- .Net分布式事務及落地解决方案
猜你喜欢
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
.Net分布式事務及落地解决方案
ROS2专题【01】:win10上安装ROS2
走入并行的世界
[quick start of Digital IC Verification] 9. Finite state machine (FSM) necessary for Verilog RTL design
Go language | 02 for loop and the use of common functions
计算lnx的一种方式
Rainbond 5.7.1 支持对接多家公有云和集群异常报警
[C language] string function and Simulation Implementation strlen & strcpy & strcat & StrCmp
Securerandom things | true and false random numbers
随机推荐
2020 CCPC 威海 - A. Golden Spirit(思维),D. ABC Conjecture(大数分解 / 思维)
Multi branch structure
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
Leetcode skimming: binary tree 16 (path sum)
C langue OJ obtenir PE, ACM démarrer OJ
C language OJ gets PE, OJ of ACM introduction~
[quick start of Digital IC Verification] 1. Talk about Digital IC Verification, understand the contents of the column, and clarify the learning objectives
Go language learning tutorial (XV)
基金网上开户安全吗?去哪里开,可以拿到低佣金?
微信小程序正则表达式提取链接
Fundamentals of deep learning convolutional neural network (CNN)
2022年7月4日-2022年7月10日(ue4视频教程mysql)
Leetcode brush question: binary tree 13 (the same tree)
c语言oj得pe,ACM入门之OJ~
Win10 x64环境下基于VS2017和cmake-gui配置使用zxing以及opencv,并实现data metrix码的简单检测
How to safely and quickly migrate from CentOS to openeuler
Float. The specific meaning of the return value of floattorawintbits is to convert float into byte array
DP: tree DP
USACO3.4 “破锣摇滚”乐队 Raucous Rockers - DP
leetcode刷题:二叉树17(从中序与后序遍历序列构造二叉树)