Database Reference
In-Depth Information
Figure 7-7. Editing a status update
The edit feature, like the add feature, uses a method in the SocialController and a function in graphstory.js ,
which are edit and updateContent , respectively. The edit method passes in the content object, with its content id,
and then calls the edit method in ContentService , as shown in Listing 7-34.
In the case of the edit feature, you do not need to update relationships. Instead, simply retrieve the existing node
by its generated String Id (not its graph id), update its properties where necessary, and save it back to the graph.
Listing 7-34. The edit Method in ContentService
public MappedContent edit(Content content, string username)
{
content.tagstr = removeTrailingComma(content.tagstr);
// splits up the comma separated string into arrays and removes any empties.
// each tag uses MERGE and connected to the the content node thru the HAS,
e.g content-[:HAS]->tag
// remember that MERGE will create if it doesn't exist otherwise based on the
properties provided
String[] tags = content.tagstr.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
MappedContent mappedContent = _graphClient.Cypher
.Match(" (c:Content {contentId:{contentId}})-[:NEXTPOST*0..]-()-[:CURRENTPOST]-(user {
username: {u}}) ")
.WithParams(new { u = username, contentId = content.contentId})
.Set(" c.title = {title}, c.url = {url}, c.tagstr = {tagstr} ")
Search WWH ::




Custom Search