0
我使用的node.js服務器上mongoose.js連接到MongoDB的填充,我有一個貓鼬模型如下所示:無法獲得Mongoose.js 3級子文檔陣
var ItemSchema = new Schema({
qtde: {
type: Number,
default: 0.0,
required: 'Digite a quantidade'
},
detalhe: {
type: Schema.ObjectId,
ref: 'Detalhe'
},
produto: {
type: Schema.ObjectId,
ref: 'Produto'
}
});
var DetalheSchema = new Schema({
dia: {
type: String,
default: '',
required: 'Digite o Dia do coffee'
},
orcamento: {
type: Schema.ObjectId,
ref: 'Orcamento'
},
itens: [{type: Schema.ObjectId, ref: 'Item' }]
});
var OrcamentoSchema = new Schema({
contato: {
type: String,
default: '',
required: 'Digite o nome do Contato',
trim: true
},
curso: {
type: String,
default: '',
required: 'Digite o Curso',
trim: true
},
dias: {
type: String,
default: '',
required: 'Digite os dias do curso',
trim: true
},
inicio: {
type: String,
required: 'Digite a Data de Início'
},
detalhes: [{type: Schema.ObjectId, ref: 'Detalhe'}]
});
mongoose.model('Item', ItemSchema);
mongoose.model('Detalhe', DetalheSchema);
mongoose.model('Orcamento', OrcamentoSchema);
我問題是我無法獲得orcamento.detalhes [n] .itens數組來填充或加載,它只是繼續顯示爲一個空數組。
感謝。我會測試貓鼬深度人口。 –
一旦你完成測試,你能接受答案嗎? –
當測試執行mogoose-deep-populate時,會發生以下錯誤:警告:檢測到可能的EventEmitter內存泄漏。 11重新連接偵聽器添加。使用emitter.setMaxListeners()來增加限制。 –