-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert.js
44 lines (40 loc) · 1013 Bytes
/
insert.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const mongoose = require('mongoose')
const password = 'sss123456789'
const url =
`mongodb+srv://sss:${password}@cluster0.rhcnb.mongodb.net/ObserverData?retryWrites=true&w=majority`
mongoose.connect(url, { useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false, useCreateIndex: true })
const noteSchema2 = new mongoose.Schema({
name:{
title:String,
finally:String,
last:String
},
email:String,
gender:String
/* active: {
type: String,
minLength: 1,
required: true
},
dead: {
type: String,
minLength: 1,
required: true
}, */
})
const Observer =mongoose.model('Observer',noteSchema2)
const observer=new Observer({
name:{
title:"mrs",
finally:"james6",
last:"brown6",
},
gender:"female",
email:"aaabbb"
/* active:"22",
dead:"32", */
})
observer.save().then(result => {
console.log('observer saved!')
mongoose.connection.close()
})