Mongoose Добавьте данные в сбор
const Name =require('path of your model')
app.use('/path', (req,res,next)=>
{
const firstName = req.body.firstName // req.body.firstName refers to your form name input
const lastName = req.body.lastName // req.body.lastName refers to your form name input
const nameData = new Name({firstName:firstName, lastName:lastName});
nameData.save().then(res.redirect('/')).catch(err){
console.log(err);
};
});
//Remember to add a model
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const addittionSchema = new Schema({
firstName:{
type: String,
required: True
},
lastName:{
type: String,
required:True
}
});
module.exports = mongoose.model('budget', addittionSchema);
Delightful Dove