我需要在子文档中插入另一个子文档 我已经看到了一些例子,但它们只能到达第一级子文档
这是我的模特
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Infonodo = require('./infonodo.model');
var personSchema = new Schema({
rfc: {type:String,required:true,unique:true},
name: {type:String,required:true},
jobs:[
{
name: {type:String,required:true},
city: {type:String},
location: {type:String},
skills: [
{
name: {type:String,required:true},
time: {type:String,required:true},
where: {type:Number,required:true},
percentage: {type:String},
_info: { type: mongoose.Schema.Types.ObjectId, ref: 'Infospecific', index: true }
}
]
}
]
});
module.exports = mongoose.model('Person', personSchema);
我不知道如何更新或插入'技能'只有我知道更新或插入工作'。
具体来说,我需要了解一份特定的工作,并在这份工作中更新或插入不同的技能。
有人能帮帮我吗?
答案 0 :(得分:0)
您是否尝试过插入广告?
var Person = require('your-module');
var person = new Person(
{ name:"Sachin Sharma"
jobs: [ { name: 'job1' , city:'New York',
skills:[name "Java", time:"3 Years",_info :"02030303"]
},
{ name: 'job2',city:'Bangalore',
skills:[name "C++", time:"2 Years",_info :"02030304"]
}
]
})