【问题标题】:An optional dict in the structure with MongoKitMongoKit 结构中的可选字典
【发布时间】:2010-08-26 15:41:53
【问题描述】:

我有这样的 MongoKit 结构:

structure = {
  ...

  'plugin': {
    'id': unicode,
    'title': unicode,
    'description': unicode,

  ...
}

但是,并非所有文档都有plugin 键。如果他们这样做,我希望根据结构对其进行验证。

required_fields包含plugin。 (plugin 不是必需的密钥。)

我试过'plugin': OR(None, {...}),但OR 不喜欢None 作为值。

有什么想法吗?

【问题讨论】:

    标签: python mongodb mongokit


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-13
    • 1970-01-01
    • 2012-09-20
    • 1970-01-01
    • 2013-12-10
    • 2011-04-13
    • 1970-01-01
    相关资源
    最近更新 更多