我声明了一个对象:
var someObject = { someField: someValue }
我有mongoose的架构:
var achievementSchema = new Schema({
_id: { type: String, required: true, unique: true },
//add reference to declared earlier object
});
module.exports = mongoose.model('Achievement', achievementSchema);
现在我想告诉mongoose,在所有新实例中创建对“someObject”的引用。
var achievement = new Achievement({
_id: "someId"
reference: //i want mongoose to automatically add reference to object that is already in memory
});
并将此引用称为:
console.log(achievement.reference);
mongoose有可能吗?