Mongoose with node (Static Data)

 



const mongoose = require('mongoose');


const main = async() =>{
    await mongoose.connect('mongodb://0.0.0.0:27017/Class12');
    const studentSchema = new mongoose.Schema({
        name:String,
        father_name:String
    });
   
    const studentModel  = mongoose.model('students',studentSchema);
    let data  = new studentModel({name:"Malti sen",father_name:"Ram"});
    let result = await data.save();
    console.log(result);
}

main()

Comments

Popular posts from this blog

React Installation with Vite and Tailwind css (Steps to Installation)

Insert Data In mongoDb

Class methods as an alternative Constructor