NOSQL – RAVENDB – Collection of non-standard references

Let’s assume I have the following domain names:

public class Movie
{
public string Id {get; set; }
public string Name {get; set; }
public List 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 referenced movies are also updated. Therefore, I first create an index that allows me to query for specific actors All movies:

public class Movies_ByActorId: AbstractIndexCreationTask
{
public Movies_ByActorId()
{
Map = movies => from movie in movies
from actor in movie.Actors
select new {ActorId = actor.Id };
}
}< /pre>

Okay, now I want to fire the patch command...

Session.Advanced.DatabaseCommands.UpdateByIndex(
"Movies/ByActorId",< br /> new IndexQuery
{
Query = "ActorId:" + actorWhoseNameHasChanged.Id
},
new[]
{
new PatchRequest
{
Type = PatchCommandType.Modify,
Name = "Actors",
Nested = new[]
{
// WHAT TO DO HERE?
}
}
},
allowStale: false);

Someone can help me complete the above code block, because I don’t know at all, how can I just Update the name of the denormalized reference representing the changed actor.

I am worried that RavenDB does not support this kind of patch request, and I need to manually load and store all movies, which I definitely want to avoid for performance reasons.

RavenDB does not support patch-based standards. You can solve the problem without denormalizing references And use include when reading.

We assume that I have the following domain names:

public class Movie
{
public string Id {get; set; }
public string Name {get; set; }
public List Actors {ge t; 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
{< br /> public string Id {get; set; }
public string Name {get; set; }
}

Now, if the actor name changes, I want to make sure that all references Movies will also be updated. Therefore, I first create an index that allows me to query all movies involving a specific actor:

public class Movies_ByActorId: AbstractIndexCreationTask
{
public Movies_ByActorId()
{
Map = movies => from movie in movies
from actor in movie.Actors
select new {ActorId = actor.Id };
}
}

Ok, now I want to fire 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);

< p>Can someone help me complete the above code block, because I have no idea, how can I only update the name of the denormalized reference representing the changed actor.

I am worried that RavenDB does not support this kind of patch request , I need to manually load and store all movies, which I definitely want to avoid for performance reasons.

RavenDB does not support patch-based standards. You can Solve the problem without denormalized references, and use include when reading.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 627 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.