【问题标题】:Can I embed a Schema within a Schema in Mongoose?我可以在 Mongoose 的 Schema 中嵌入 Schema 吗?
【发布时间】:2011-11-22 08:35:24
【问题描述】:
SocialProfileSchema = new mongoose.Schema
  source: String
  user_id: String
  profile_url: String

UserProfileSchema  = new mongoose.Schema
    socialProfiles: [SocialProfileSchema]

这是我的代码。有效吗?

【问题讨论】:

    标签: node.js mongoose


    【解决方案1】:

    是的!事实证明这是有效的!

    【讨论】:

      【解决方案2】:

      该代码将在 UserProfiles 中创建一个嵌入的 SocialProfiles 文档数组 -- http://mongoosejs.com/docs/embedded-documents.html

      【讨论】:

        猜你喜欢
        • 2015-09-14
        • 2019-09-09
        • 2011-07-01
        • 2015-04-11
        • 1970-01-01
        • 2021-10-06
        • 2021-10-21
        • 1970-01-01
        • 2023-02-01
        相关资源
        最近更新 更多