-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.js
More file actions
65 lines (61 loc) · 1.39 KB
/
init.js
File metadata and controls
65 lines (61 loc) · 1.39 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const mongoose = require("mongoose");
const Chat = require("./models/chat.js");
main().then(()=>{
console.log("Connected to MongoDB");
}).catch((err)=>{
console.log(err);
})
async function main(){
await mongoose.connect("mongodb://127.0.0.1:27017/fakewhatsapp")
}
let chats = [
{
from: "Hari",
to: "harshit",
message: "Today i will not go there.",
created_at: new Date(),
},
{
from: "pritam",
to: "pragyan",
message: "Today i will not go to the gym.",
created_at: new Date(),
},
{
from: "pritisha",
to: "pragyan",
message: "I love youuuuu",
created_at: new Date(),
},
{
from: "alex",
to: "hiya",
message: "What are you doing baby",
created_at: new Date(),
},
{
from: "mazulika",
to: "akshay",
message: "Ami Manzulikaaaaa!!",
created_at: new Date(),
},
{
from: "sohan",
to: "pragyan",
message: "Where is the Key?",
created_at: new Date(),
},
{
from: "Krishna",
to: "arjun",
message: "Donot think about result, do your work constantly",
created_at: new Date(),
}
]
Chat.insertMany(chats)
.then((res) => {
console.log("Documents inserted:", res);
})
.catch((err) => {
console.error("Error inserting documents:", err);
});;