"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Mongoose Documentation

Mongoose Documentation

Published on 2024-08-06
Browse:244

Mongoose Documentation

install mangoose

npm install mongoose

.
.
To connect to the mongodb by using mongoose
ex:app.js

const mongoose=require('mongoose');
mongoose
    .connect('url');
    .then(res=>app.listen(3000));
    .catch(err=>console.log(err));

.
.
To create schema
ex:model folder student.js

const mongoose = require('mongoose');
const studentSchema = mongoose.Schema({
    name:{
        type:String,
        required:true
    },
    studentid:{
        type:Number,
        required:true
    }
});
module.exports=mongoose.model('students',studentSchema);

.
.
To create a students
ex:controllers folder

console.log('hi')
Release Statement This article is reproduced at: https://dev.to/munisekharudavalapat/mongoose-documentation-jdc?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3