私は2つのコレクションを持っています:
//col1
var schema1 = new mongoose.Schema({
_id: ... ,
name1: String,
objects1: [{
_id: ... , <-- reference to this !!!!!!!!!!!!!!
obj_name: String
}]
});
//col2
var schema2 = new mongoose.Schema({
_id: ... ,
name2 : String,
objects2 : [{
_id: ... ,
_source: {type: mongoose.Schema.ObjectId, ref: 'col1'}
}]
});
私が何かをするなら
schema.statics.getByName = function(name, callback) {
mongoose.model('col2').findOne({ name2 : name }).populate('objects2').exec(callback);
};
戻りオブジェクトは移入されません。
問題は、私が参照しているオブジェクトが配列に格納されており、それがドキュメント ID ではないことだと確信しています。
これを解決しようとしまし_source: {type: mongoose.Schema.ObjectId, ref: 'col1.objects1'}
たが、何の効果もありませんでした。
何か案は?