Suppose I have the following domain:
public class Movie { public string Id { get; set; } public string Name { get; set; } public List<ActorReference> Actors { get; set; } } public class Actor { public string Id { get; set; } public string Name { get; set; } public string Biography { get; set; } public string AnotherDetailProperty { get; set; } } public class ActorReference { public string Id { get; set; } public string Name { get; set; } }
Now, if the actorβs name changes, I want to make sure that all links to films are also updated. Therefore, I first create an Index that allows me to query all the films in which a particular actor is involved:
public class Movies_ByActorId : AbstractIndexCreationTask<Movie> { public Movies_ByActorId() { Map = movies => from movie in movies from actor in movie.Actors select new { ActorId = actor.Id }; } }
Ok, now I would like to run the patch command ...
Session.Advanced.DatabaseCommands.UpdateByIndex( "Movies/ByActorId", new IndexQuery { Query = "ActorId:" + actorWhoseNameHasChanged.Id }, new[] { new PatchRequest { Type = PatchCommandType.Modify, Name = "Actors", Nested = new[] { // WHAT TO DO HERE? } } }, allowStale: false);
Can someone please help me fill out this code block above, since I have absolutely no idea how I can only update the name of the denormalized links that the modified actor represents.
I am afraid that RavenDB does not support such a patch request, and I need to download and store all the films manually, which I definitely want to avoid for performance reasons.
source share