【问题标题】:Doctrine ODM / MongoDB: index on embedded documentsDoctrine ODM / MongoDB:嵌入文档的索引
【发布时间】:2012-12-20 18:04:36
【问题描述】:

在我的应用程序中,我嵌入了两个名称不同但 targetDocument 相同的文档

# yml mapping
Content\Post:
    type: document
    embedOne:
        facebook:
            targetDocument: Content\PostEmbed
        twitter:
            targetDocument: Content\PostEmbed

嵌入文档有一个带索引的字段value

Content\PostEmbed:
    type: embeddedDocument
    fields:
        value:
            type: int
            index:
                order: desc

我的问题是当我运行MongoDb ODM的更新命令时,只创建了facebook.value上的索引,没有为twitter.value创建索引

我当然可以手动创建它,但我想知道它是否有特殊的语法

【问题讨论】:

    标签: doctrine-odm


    【解决方案1】:

    您是否尝试过 yaml 标记的替代语法?

    http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/yml-mapping.html

    Content\Post:
      type: document
      facebook:
        embedded: true
        type: one
        targetDocument: Content\PostEmbed
      twitter:
        embedded: true
        type: one
        targetDocument: Content\PostEmbed
    

    【讨论】:

      猜你喜欢
      • 2012-01-16
      • 2012-06-11
      • 2016-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多