开发者

Can I embed a Schema within a Schema in Mongoose?

SocialProfileSchema = new mongoose.Schema
  source: String
  user_id: String
  profile_url: String

UserProfileSchema  = new mongoose.Schema
    socia开发者_JAVA百科lProfiles: [SocialProfileSchema]

That's my code. Is it valid?


Yes! This is valid it turns out!


That code will create an embedded documents array of SocialProfiles within UserProfiles -- http://mongoosejs.com/docs/embedded-documents.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜