“Mongoose Dodaj dane do kolekcji” Kod odpowiedzi

Mongoose Dodaj dokument

const Product = require('../models/product.js');

const product = new Product();
product.save()
		.then(doc => {})
        .catch(err => {});
Scary Snail

Mongoose Dodaj dane do kolekcji

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

Odpowiedzi podobne do “Mongoose Dodaj dane do kolekcji”

Pytania podobne do “Mongoose Dodaj dane do kolekcji”

Więcej pokrewnych odpowiedzi na “Mongoose Dodaj dane do kolekcji” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu