-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
51 lines (40 loc) · 987 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
41
42
43
44
45
46
47
48
49
50
51
const mongoose = require('mongoose');
const Chat = require("./models/chats.js")
main()
.then(()=>{
console.log("connection Sccessful")
})
.catch((err) =>
console.log(err)
);
async function main() {
await mongoose.connect('mongodb://127.0.0.1:27017/WhatsApp');
// use `await mongoose.connect('mongodb://user:password@127.0.0.1:27017/test');` if your database has auth enabled
}
let allChats = [
{
from: "neha",
to : "kajal",
msg: "send me exam sheet",
created_at : new Date(), // js new function to generate the data
},
{
from: "jay",
to : "kiran",
msg: "send me exam sheet",
created_at : new Date(),
},
{
from: "prachi",
to : "hitesh",
msg: "send me exam sheet",
created_at : new Date(),
},
{
from: "sudeep",
to : "divya",
msg: "send me exam sheet",
created_at : new Date(),
},
];
Chat.insertMany(allChats);