对于mongoengine ODM,嵌套词典的最佳实践是什么?

时间:2016-08-11 09:18:01

标签: python mongodb dictionary mongoengine

我的MongoDB中有一些这样的数据:

dispatch

如何使用mongoengine ODM对其进行建模?

1 个答案:

答案 0 :(得分:0)

您可以使用embedded document字段来创建字典的嵌套结构。这样的事情应该有效:

from mongoengine import Document, EmbeddedDocument
class FetchedZipSize(EmbeddedDocument):
    a=IntField()
    b=IntField()

class CollectionName(Document):
    fetchedZipSize = EmbeddedDocumentField(FetchedZipSize)