0

The following is the structure of my content in MongoDB

{
  partnerName: "Zumba Fitness",
  supportedProducts: [
   "Fitness 1.0",
   "Protein Bars"
  ]
}

I want to modify/update the contents of supportedProducts upon a PATCH request. For example, I want to change Fitness 1.0 to Fitness 2.0

I am unsure how the request for PATCH from the client side will look like. Would be it something as following

  PATCH /data/{partnerName}
  Content-Type: application/json

  [
    { op: "replace", path: "/supportedProducts", value: "Fitness 2.0" }
  ]

I have tried the above, but it did not modify the content in my database

4

1 回答 1

0

RFC 6902说 JSON Patch 的媒体类型是

application/json-patch+json

我已经尝试了上述方法,但它没有修改我数据库中的内容

我不希望这会魔法发生。您仍然需要调用将应用补丁的代码。例如:jsonpatch-to-mongodb

于 2017-07-13T01:40:03.883 回答