当前位置:网站首页>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;
边栏推荐
- CTF逆向基础
- 解决php无法将string转换为json的办法
- CADD课程学习(7)-- 模拟靶点和小分子相互作用 (半柔性对接 AutoDock)
- ICTCLAS用的字Lucene4.9捆绑
- Database logic processing function
- Go language learning tutorial (XV)
- 计算lnx的一种方式
- Solve the problem that the database configuration information under the ThinkPHP framework application directory is still connected by default after modification
- ICTCLAS word Lucene 4.9 binding
- [quick start of Digital IC Verification] 3. Introduction to the whole process of Digital IC Design
猜你喜欢
A solution to PHP's inability to convert strings into JSON
走入并行的世界
leetcode刷题:二叉树11(平衡二叉树)
Go language | 01 wsl+vscode environment construction pit avoidance Guide
2023年深圳市绿色低碳产业扶持计划申报指南
leetcode刷题:二叉树18(最大二叉树)
Oracle-表空间管理
【愚公系列】2022年7月 Go教学课程 004-Go代码注释
Debezium series: record the messages parsed by debezium and the solutions after the MariaDB database deletes multiple temporary tables
【数字IC验证快速入门】8、数字IC中的典型电路及其对应的Verilog描述方法
随机推荐
Guidelines for application of Shenzhen green and low carbon industry support plan in 2023
【数字IC验证快速入门】7、验证岗位中必备的数字电路基础知识(含常见面试题)
Leetcode brush questions: binary tree 11 (balanced binary tree)
[quick start of Digital IC Verification] 1. Talk about Digital IC Verification, understand the contents of the column, and clarify the learning objectives
How to select the Block Editor? Impression notes verse, notation, flowus
USACO3.4 “破锣摇滚”乐队 Raucous Rockers - DP
leetcode刷题:二叉树12(二叉树的所有路径)
死信队列入门(两个消费者,一个生产者)
【数字IC验证快速入门】2、通过一个SoC项目实例,了解SoC的架构,初探数字系统设计流程
【数字IC验证快速入门】1、浅谈数字IC验证,了解专栏内容,明确学习目标
leetcode刷题:二叉树15(找树左下角的值)
After 95, Alibaba P7 published the payroll: it's really fragrant to make up this
.Net分布式事務及落地解决方案
Practical demonstration: how can the production research team efficiently build the requirements workflow?
mongodb/文档操作
Some problems encountered in cocos2d-x project summary
本季度干货导航 | 2022年Q2
IC科普文:ECO的那些事儿
1:引文;
随机数生成的四种方法|Random|Math|ThreadLocalRandom|SecurityRandom