Initialize Database
WE CREATE INIT.JS - USED TO STORE
const mongoose = require("mongoose");
const Chat = require("./models/chat.js");
main()
.then(() => {
console.log("connection successful");
})
.catch((err) => {
console.log(err);
});
async function main() {
await mongoose.connect("mongodb://127.0.0.1:27017/whatsapp");
}
let allChats=[
{
from:"ash",
to:"bharath",
msg:"ee saala cup uu lollipup uu",
created_at:new Date()
},
{
from:"abhi",
to:"bharath",
msg:"ee saala cup uu lollipup uu",
created_at:new Date()
},{
from:"abhi",
to:"vinay",
msg:"Khansaar erupekkala",
created_at:new Date()
},{
from:"vinay",
to:"bharath",
msg:"ee saala cup namde",
created_at:new Date()
}
];
Chat.insertMany(allChats);

Comments
Post a Comment