0

我正在为 RavenDB 编写节点包装器。

我使用的是版本 3,但由于没有 HTTP 文档,我一直依赖 2.0 和 2.5 文档。

关于单个文档操作,我已经成功地将这个文档页面用于 PUT、DELETE 和多个 PATCH 到单个文档。

同样,我已经在一个 HTTP 调用中成功地将此文档页面用于多个文档的多个 PUT 和 DELETE,但是在一次调用中 PATCHing 多个文档的文档有点模糊

在“批处理请求”标题下,它清楚地表明这是可能的:

RavenDB 中的请求批处理是使用“/bulk_docs”端点处理的,该端点接受要执行的操作数组。操作的格式是:

方法 - PUT、PATCH 或 DELETE。

...

对于 PUT,我 POST 到 /bulk_docs:

[
  {
    Method: 'PUT',
    Key: 'users/1',
    Document: { username: 'dummy' }
    Metadata: { 'Raven-Entity-Type': 'Users' }
  },
  ...
]

对于 DELETE,我 POST 到 /bulk_docs:

[
  {
    Method: 'DELETE',
    Key: 'users/1'
  },
  ...
]

对于补丁,我尝试发布以下内容,但没有任何运气:

[
  {
    Method: 'PATCH',
    Key: 'users/1',
    Document: {
      Type: 'Set',
      Name:'username',
      Value: 'new-username'
    }
  },
  ...
]

[
  {
    Method: 'PATCH',
    Key: 'users/1',
    Type: 'Set',
    Name:'username',
    Value: 'new-username'
  },
  ...
]

我得到的只是500 - Internal Server Error并且没有任何在该文档页面上修补多个文档的示例,我有点卡住了......

任何帮助,将不胜感激 :)

4

1 回答 1

0

PATCH 的结构是:

[
  {
    Method: 'PATCH',
    Key: 'users/1',
    Patches: [{
Type: 'Set',
        Name:'username',
        Value: 'new-username'
}]
  },
  ...
]

完整的结构可以在这里看到: https ://github.com/ayende/ravendb/blob/master/Raven.Abstractions/Commands/PatchCommandData.cs#L72

于 2015-04-26T12:31:41.803 回答