Patching entire object in array at specified position

17 views
Skip to first unread message

sga...@gmail.com

unread,
Sep 11, 2015, 6:54:01 PM9/11/15
to RavenDB - 2nd generation document database
So I have read the documentation and know how to do nested patches on arrays of objects, but only when I know the particular field that should be patched. Is there a way to patch the entire object?

For example, if i had the following objects

class Blog
{
   
string Id {get;set;}
   
BlogComment[] Comments {get;set;}
}


class BlogComment
{
   
string Title {get;set;}
   
string Text {get;set;}
}


and my data looked something like:

{
   
Id: "Blogs/1",
   
BlogComments: [
       
{ Title: "First", Text: "Some text" },
       
{ Title: "Second", Text: "Some more text" }

   
]
}


and I wanted to replace the entire first element in the array with a new object so that it would look like:

{
   
Id: "Blogs/1",
   
BlogComments: [
       
{ Title: "Patch Updated Title", Text: "Patch updated text" },
       
{ Title: "Second", Text: "Some more text" }

   
]
}


Can I do this type of update with a Patch request?

Oren Eini (Ayende Rahien)

unread,
Sep 11, 2015, 7:01:05 PM9/11/15
to ravendb
This is probably easier:

The feature is named scripted Patching, though.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sga...@gmail.com

unread,
Sep 11, 2015, 7:41:46 PM9/11/15
to RavenDB - 2nd generation document database
This worked perfectly! Thanks Oren.
Reply all
Reply to author
Forward
0 new messages