当前位置:网站首页>Schema和Model
Schema和Model
2022-07-05 20:11:00 【为什么不好好卖蛋饼】
16 Schema和Model
Schema
Model
Document
顺序从上往下
var mongoose=require("mongoose");
mongoose.connect('mongodb://数据库ip地址:端口号/数据库名',{
userMongoClient:true});
mongoose.connection.once("open",function(){
console.log("数据库连接成功");
});
//创建模式对象
var Schema=mongoose.Schema;
var stuSchema=new Schema({
title:String,
age:Number,
gender:{
type:String,
default:"female"
},
address:String
});
//model代表集合,通过model才能对数据库操作
var StuModel=mongoose.model('Student',stuSchema);
//向数据库插入一个文档
StuModel.create({
name:"孙悟空",
age"18,
gender:"male",
address:"花果山"
},function(err){
if(!err){
console.log("插入成功");
}
});
创建模型(集合名,约束对象)
模型操作数据库
边栏推荐
- 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
- [quick start of Digital IC Verification] 1. Talk about Digital IC Verification, understand the contents of the column, and clarify the learning objectives
- S7-200smart uses V90 Modbus communication control library to control the specific methods and steps of V90 servo
- Redis cluster simulated message queue
- DP:树DP
- A way to calculate LNX
- Leetcode skimming: binary tree 10 (number of nodes of a complete binary tree)
- 【数字IC验证快速入门】2、通过一个SoC项目实例,了解SoC的架构,初探数字系统设计流程
- Securerandom things | true and false random numbers
- Summer Challenge harmonyos - realize message notification function
猜你喜欢

js实现禁止网页缩放(Ctrl+鼠标、+、-缩放有效亲测)

Win10 x64环境下基于VS2017和cmake-gui配置使用zxing以及opencv,并实现data metrix码的简单检测

Leetcode skimming: binary tree 17 (construct binary tree from middle order and post order traversal sequence)

微信小程序正则表达式提取链接

实操演示:产研团队如何高效构建需求工作流?

leetcode刷题:二叉树17(从中序与后序遍历序列构造二叉树)

Go language | 03 array, pointer, slice usage

基础篇——配置文件解析

Convolution free backbone network: Pyramid transformer to improve the accuracy of target detection / segmentation and other tasks (with source code)

ROS2专题【01】:win10上安装ROS2
随机推荐
Process file and directory names
Some problems encountered in cocos2d-x project summary
点云文件的.dat文件读取保存
2023年深圳市绿色低碳产业扶持计划申报指南
挖财钱堂教育靠谱安全吗?
【数字IC验证快速入门】1、浅谈数字IC验证,了解专栏内容,明确学习目标
-v parameter of GST launch
微信小程序正则表达式提取链接
CADD课程学习(7)-- 模拟靶点和小分子相互作用 (半柔性对接 AutoDock)
BZOJ 3747 POI2015 Kinoman 段树
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
Jvmrandom cannot set seeds | problem tracing | source code tracing
Bzoj 3747 poi2015 kinoman segment tree
Rainbond 5.7.1 支持对接多家公有云和集群异常报警
Leetcode(695)——岛屿的最大面积
leetcode刷题:二叉树10(完全二叉树的节点个数)
E. Singhal and Numbers(质因数分解)
JVMRandom不可设置种子|问题追溯|源码追溯
A solution to PHP's inability to convert strings into JSON
浅浅的谈一下ThreadLocalInsecureRandom