【问题标题】:Embedded Collection of Same Type同类型的嵌入式集合
【发布时间】:2017-08-28 12:56:45
【问题描述】:

我的收藏中有一个名为“字段”的文档。我需要在字段中嵌入一组字段子项。我正在使用 GORM 来处理域建模并坚持到集合中,一切似乎都保存得很好。但是,当我查询该集合时,我发现有些不对劲:

/* 11 */
{
    "_id" : NumberLong(11),
    "dateCreated" : ISODate("2017-08-28T08:42:39.511-04:00"),
    "description" : "An embedded fieldset",
    "fields" : [ 
        NumberLong(12), 
        NumberLong(13)
    ],
    "lastUpdated" : ISODate("2017-08-28T08:42:39.511-04:00"),
    "name" : "embeddedFieldset",
}

/* 12 */
{
    "_id" : NumberLong(14),
    "dateCreated" : ISODate("2017-08-28T08:42:39.512-04:00"),
    "description" : "Favorite Number?",
    "lastUpdated" : ISODate("2017-08-28T08:42:39.512-04:00"),
    "name" : "favoriteNumber",
}

请注意,ID 为 11 的字段有 2 个嵌入字段(ID 为 12 和 13),但集合中的下一个字段的 ID 为 14。所以看起来确实存在 12 和 13,但我没有根本看不到它们在集合中。那么,他们在哪里?

【问题讨论】:

    标签: mongodb grails grails-orm nosql


    【解决方案1】:

    我的错。嵌入字段中存在错误,导致它们无法保存到数据库中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-07
      • 2021-03-11
      • 1970-01-01
      • 2022-11-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多