【问题标题】:How to model schema for list of embedded dictionaires in python eve如何在 python eve 中为嵌入式字典列表建模模式
【发布时间】:2016-05-16 17:51:54
【问题描述】:

我有一个文档,其中用户有 2 个地址,如下所示。如何在 python-eve 中为此创建模式?

另外,我将如何创建 API 请求以允许用户仅更新邮政编码。他们是否必须重新发布整个文档?

{
   _id: "joe",
   name: "Joe Bookreader",
   addresses: [
                {
                  street: "123 Fake Street",
                  city: "Faketon",
                  state: "MA",
                  zip: "12345"
                },
                {
                  street: "1 Some Other Street",
                  city: "Boston",
                  state: "MA",
                  zip: "12345"
                }
              ]
 }

【问题讨论】:

    标签: eve


    【解决方案1】:

    就架构而言,这应该可以解决问题 (docs):

    'addresses': {
        'type': 'list',
        'schema' {
            'type': 'dict',
            'schema': {
                'street': {'type': 'string'},
                'city': {'type': 'string'},
                'state': {'type': 'string'},
                'zip': {'type': 'string'}
             }
         }
     }
    

    PATCH(更新)请求支持点表示法,但文档列表中不支持。它们更棘手,而且很难以 RESTful 方式完成。现在有一个open ticket,但恐怕还没有直接的解决方案。

    【讨论】:

    • 能否为问题中的数据添加完整架构?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多