当前位置:网站首页>Schema and model
Schema and model
2022-07-05 20:17:00 【Why not sell egg cakes well】
16 Schema and Model
Schema
Model
Document
From top to bottom
var mongoose=require("mongoose");
mongoose.connect('mongodb:// database ip Address : Port number / Database name ',{
userMongoClient:true});
mongoose.connection.once("open",function(){
console.log(" Database connection successful ");
});
// Create a schema object
var Schema=mongoose.Schema;
var stuSchema=new Schema({
title:String,
age:Number,
gender:{
type:String,
default:"female"
},
address:String
});
//model For the assembly , adopt model To operate on the database
var StuModel=mongoose.model('Student',stuSchema);
// Insert a document into the database
StuModel.create({
name:" The Monkey King ",
age"18,
gender:"male",
address:" Huaguoshan "
},function(err){
if(!err){
console.log(" Insert the success ");
}
});
Creating models ( Collection name , Constrain objects )
Model operation database
边栏推荐
- leetcode刷题:二叉树17(从中序与后序遍历序列构造二叉树)
- Mysql频繁操作出现锁表问题
- model方法
- 2020 CCPC 威海 - A. Golden Spirit(思维),D. ABC Conjecture(大数分解 / 思维)
- About the priority of Bram IP reset
- .Net分布式事务及落地解决方案
- Ffplay document [easy to understand]
- How to choose a good external disk platform, safe and formal?
- Jvmrandom cannot set seeds | problem tracing | source code tracing
- .Net分布式事務及落地解决方案
猜你喜欢

Enter the parallel world

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

Guidelines for application of Shenzhen green and low carbon industry support plan in 2023

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

CVPR 2022 | 常见3D损坏和数据增强

【数字IC验证快速入门】3、数字IC设计全流程介绍
![[quick start of Digital IC Verification] 9. Finite state machine (FSM) necessary for Verilog RTL design](/img/32/a156293f145417eeae8d93c539ca55.png)
[quick start of Digital IC Verification] 9. Finite state machine (FSM) necessary for Verilog RTL design
![[quick start of Digital IC Verification] 7. Basic knowledge of digital circuits necessary for verification positions (including common interview questions)](/img/90/aad9d7900d686efca10140717a5c5c.png)
[quick start of Digital IC Verification] 7. Basic knowledge of digital circuits necessary for verification positions (including common interview questions)

Oracle tablespace management

如何形成规范的接口文档
随机推荐
Guidelines for application of Shenzhen green and low carbon industry support plan in 2023
c语言oj得pe,ACM入门之OJ~
ICTCLAS word Lucene 4.9 binding
强化学习-学习笔记4 | Actor-Critic
MySql的root密码忘记该怎么找回
银河证券在网上开户安全吗?
怎么挑选好的外盘平台,安全正规的?
Debezium series: PostgreSQL loads the correct last submission LSN from the offset
Debezium series: modify the source code to support drop foreign key if exists FK
Debezium series: modify the source code to support UNIX_ timestamp() as DEFAULT value
leetcode刷题:二叉树18(最大二叉树)
C language OJ gets PE, OJ of ACM introduction~
Autumn byte interviewer asked you any questions? In fact, you have stepped on thunder
js方法传Long类型id值时会出现精确损失
Ffplay document [easy to understand]
炒股开户最低佣金,低佣金开户去哪里手机上开户安全吗
BZOJ 3747 POI2015 Kinoman 段树
Station B up builds the world's first pure red stone neural network, pornographic detection based on deep learning action recognition, Chen Tianqi's course progress of machine science compilation MLC,
Go language learning tutorial (XV)
【数字IC验证快速入门】1、浅谈数字IC验证,了解专栏内容,明确学习目标