开发者

Can I embed a Schema within a Schema in Mongoose?

开发者 https://www.devze.com 2023-04-06 18:34 出处:网络
SocialProfileSchema = new mongoose.Schema source: String user_id: String profile_url: String UserProfileSchema= new mongoose.Schema
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

精彩评论

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

关注公众号