-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
40 lines (38 loc) · 821 Bytes
/
init.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
const mongoose = require('mongoose');
const chat = require('./models/chat');
main()
.then(() => {
console.log("connection successfull");
})
.catch((err) => {
console.log("Error : ", err);
});
async function main() {
await mongoose.connect("mongodb://127.0.0.1:27017/whatsapp");
}
chat.insertMany(
[{
from: 'amit',
to: 'sumit',
msg: 'hi there',
created_At: new Date()
},
{
from: 'aashika',
to: 'bhumika',
msg: 'whats! up',
created_At: new Date()
},
{
from: 'aakash',
to: 'baman',
msg: 'teach me js',
created_At: new Date()
}]
)
.then((resp) => {
console.log("Success ! ", resp);
})
.catch((err) => {
console.log("Error : ", err);
})