当前位置:网站首页>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
边栏推荐
- 信息学奥赛一本通 1340:【例3-5】扩展二叉树
- Leetcode brush questions: binary tree 11 (balanced binary tree)
- Debezium series: modify the source code to support drop foreign key if exists FK
- 中金财富在网上开户安全吗?
- B站UP搭建世界首个纯红石神经网络、基于深度学习动作识别的色情检测、陈天奇《机器学编译MLC》课程进展、AI前沿论文 | ShowMeAI资讯日报 #07.05
- Notes on key vocabulary in the English original of the biography of jobs (12) [chapter ten & eleven]
- 14. Users, groups, and permissions (14)
- Wechat applet regular expression extraction link
- nprogress插件 进度条
- mongodb/文档操作
猜你喜欢
Unity editor extended UI control
kubernetes资源对象介绍及常用命令(五)-(ConfigMap&Secret)
【数字IC验证快速入门】6、Questasim 快速上手使用(以全加器设计与验证为例)
SecureRandom那些事|真伪随机数
信息学奥赛一本通 1339:【例3-4】求后序遍历 | 洛谷 P1827 [USACO3.4] 美国血统 American Heritage
无卷积骨干网络:金字塔Transformer,提升目标检测/分割等任务精度(附源代码)...
CVPR 2022 | 常见3D损坏和数据增强
Securerandom things | true and false random numbers
Hong Kong stocks will welcome the "best ten yuan store". Can famous creative products break through through the IPO?
Solve the problem that the database configuration information under the ThinkPHP framework application directory is still connected by default after modification
随机推荐
How to choose a good external disk platform, safe and formal?
字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验
Practical demonstration: how can the production research team efficiently build the requirements workflow?
MySql的root密码忘记该怎么找回
Leetcode(347)——前 K 个高频元素
信息学奥赛一本通 1338:【例3-3】医院设置 | 洛谷 P1364 医院设置
ROS2专题【01】:win10上安装ROS2
Jvmrandom cannot set seeds | problem tracing | source code tracing
【c语言】归并排序
【数字IC验证快速入门】8、数字IC中的典型电路及其对应的Verilog描述方法
【数字IC验证快速入门】9、Verilog RTL设计必会的有限状态机(FSM)
Parler de threadlocal insecurerandom
Zero cloud new UI design
Build your own website (16)
Notes on key vocabulary in the English original of the biography of jobs (12) [chapter ten & eleven]
nprogress插件 进度条
Rainbond 5.7.1 支持对接多家公有云和集群异常报警
零道云新UI设计中
【愚公系列】2022年7月 Go教学课程 004-Go代码注释
Let's talk about threadlocalinsecurerandom