How to reference another schema in my Mongoose schema?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm building a Mongoose schema for a dating app. I want each person document to contain a reference to all the events they've been to, where events is another schema with its own models in the system. How can I describe this in the schema? var personSchema = mongoose.Schema({ firstname: String, lastname: String, email: String, gender: {type: String, enum: ["Male", "Female"]} dob: Date, city: String, interests: [interestsSchema], eventsAttended: ??? }); 回答1: You can describe it by using Population Population is the process of automatically