-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitdb.js
More file actions
43 lines (38 loc) · 746 Bytes
/
initdb.js
File metadata and controls
43 lines (38 loc) · 746 Bytes
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
const mongoose=require("mongoose");
const chat=require("./model/chat.js");
//making connection with mongodb
main()
.then((res)=>{
console.log("Connection Successful")
})
.catch(err => console.log(err));
async function main() {
await mongoose.connect('mongodb://127.0.0.1:27017/Chatapp');
}
let allchat=[{
from:"Shyamal",
msg:"Give me a blue pen",
to:"Dipen",
created_at:new Date()
},{
from:"ssd",
msg:"let's go out ",
to:"h2",
created_at:new Date()
},{
from:"kumra",
msg:"how is your study going on",
to:"adam",
created_at:new Date()
},{
from:"Bob",
msg:"get ready",
to:"eve",
created_at:new Date()
}]
chat.insertMany(allchat).then((res)=>{
console.log(res);
})
.catch((err)=>{
console.log(err);
})