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

user8222014
  • 113
  • 1
  • 1
  • 4

1 Answers1

0

RFC 6902 says the media type for JSON Patch is

application/json-patch+json

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

I wouldn't expect that to happen by magic; you are still going to need to invoke code that will apply the patch. For example: jsonpatch-to-mongodb

Community
  • 1
  • 1
VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91