当前位置:网站首页>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
边栏推荐
- Go language | 01 wsl+vscode environment construction pit avoidance Guide
- SecureRandom那些事|真伪随机数
- Leetcode(695)——岛屿的最大面积
- E. Singhal and Numbers(质因数分解)
- Flume series: interceptor filtering data
- [C language] three implementations of quick sorting and optimization details
- Leetcode skimming: binary tree 16 (path sum)
- Schema和Model
- 微信小程序正则表达式提取链接
- A way to calculate LNX
猜你喜欢
[quick start of Digital IC Verification] 7. Basic knowledge of digital circuits necessary for verification positions (including common interview questions)
Leetcode(695)——岛屿的最大面积
Leetcode: binary tree 15 (find the value in the lower left corner of the tree)
leetcode刷题:二叉树17(从中序与后序遍历序列构造二叉树)
ROS2专题【01】:win10上安装ROS2
leetcode刷题:二叉树15(找树左下角的值)
2023年深圳市绿色低碳产业扶持计划申报指南
Securerandom things | true and false random numbers
PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
.Net分布式事务及落地解决方案
随机推荐
JVMRandom不可设置种子|问题追溯|源码追溯
What is PyC file
leetcode刷题:二叉树13(相同的树)
leetcode刷题:二叉树10(完全二叉树的节点个数)
Leetcode skimming: binary tree 12 (all paths of binary tree)
USACO3.4 “破锣摇滚”乐队 Raucous Rockers - DP
js方法传Long类型id值时会出现精确损失
A solution to PHP's inability to convert strings into JSON
解决Thinkphp框架应用目录下数据库配置信息修改后依然按默认方式连接
信息学奥赛一本通 1338:【例3-3】医院设置 | 洛谷 P1364 医院设置
Guidelines for application of Shenzhen green and low carbon industry support plan in 2023
c语言oj得pe,ACM入门之OJ~
Debezium series: modify the source code to support UNIX_ timestamp() as DEFAULT value
PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
本季度干货导航 | 2022年Q2
《乔布斯传》英文原著重点词汇笔记(十二)【 chapter ten & eleven】
B站UP搭建世界首个纯红石神经网络、基于深度学习动作识别的色情检测、陈天奇《机器学编译MLC》课程进展、AI前沿论文 | ShowMeAI资讯日报 #07.05
leetcode刷题:二叉树11(平衡二叉树)
Four methods of random number generation | random | math | threadlocalrandom | securityrandom
Scala basics [HelloWorld code parsing, variables and identifiers]