хочу знать, как сделать правильный пост-запрос для сложной модели
app.post('/tree',(req,res)=>{
var tree = new Tree({
firstName: req.body.firstName,
middleName: req.body.middleName,
lastName: req.body.lastName,
alias: [],
father: req.body.father,
mother: req.body.mother,
relationship: [
{
relation: req.body.relation,
children: []
}
]
});
})
это схема
var mongoose = require('mongoose');
var ObjectId = mongoose.Schema.Types.ObjectId;
var schema = new mongoose.Schema({
firstName: {
type: String,
required: true,
minlength:1,
trim:true
},
middleName: {
type: String,
trim: true
},
lastName: {
type: String,
trim: true
},
alias: [String],
father: ObjectId,
mother: ObjectId,
relationship: [
{
relation: ObjectId,
children: [ObjectId]
}
]
});
var Tree = mongoose.model('Tree',schema);
module.exports = {Tree};
Я новичок в программировании, поэтому извините, если это глуповопрос.надеюсь, что предоставленные мной данные достаточны, чтобы получить правильный ответ.