代码如下:
const mongoose = require('mongoose');
mongoose.connect('mongodb://127.0.0.1:81192/lets-go-brandon',{
useNewUrlParser: true,
useUnifiedTopology: true
})
const db = mongoose.connection;
db.on('error',()=>{
console.log('***数据库连接失败***')
});
db.on('open',()=>{
console.log('***数据库连接成功***')
});
const tubeSchema = mongoose.Schema({
name: String,
parentId: mongoose.Types.ObjectId,
geometry:{
"type":{
type:String,
default:"LineString",
},
coordinates:[[Number]]
},
updateTime: {
type: Date,
default: Date.now()
},
createTime: {
type: Date,
default: Date.now()
},
});
const Tube=mongoose.model("tube", tubeSchema, "tubes");
let obj={
name: "aaa",
geometry:{
type:"LineString",
coordinates:[[1,2],[2,3],[3,4]]
},
};
Tube.create(obj);
本文分享自 传输过程数值模拟学习笔记 微信公众号,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文参与 腾讯云自媒体同步曝光计划 ,欢迎热爱写作的你一起参与!