-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.js
More file actions
50 lines (46 loc) · 1001 Bytes
/
Copy pathinit.js
File metadata and controls
50 lines (46 loc) · 1001 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
44
45
46
47
48
49
50
const mongoose = require("mongoose");
// load environment variables from .env when running this script
require("dotenv").config();
const Chat = require("./models/chat");
async function main() {
const uri = process.env.MONGODB_URI || "mongodb://127.0.0.1/OpenWall";
await mongoose.connect(uri);
}
main()
.then(() => {
console.log("connection successful");
})
.catch((err) => console.log(err));
let allChats = [
{
from: "neha",
to: "preeti",
message: "send me notes for the exam",
created_at: new Date(),
},
{
from: "rohit",
to: "mohit",
message: "teach me JS callbacks",
created_at: new Date(),
},
{
from: "amit",
to: "sumit",
message: "all the best !",
created_at: new Date(),
},
{
from: "anita",
to: "ramesh",
message: "bring me some fruits",
created_at: new Date(),
},
{
from: "tony",
to: "peter",
message: "love you 3000",
created_at: new Date(),
},
];
Chat.insertMany(allChats);