pmikstacki/SliccDB

dynamically adding properties to a node

Closed this issue · 2 comments

Hello,

I am researching C# Graph databases and was wondering if it is possible to dynamically add, remove, or modify properties of existing nodes after they have been added.

I would guess that this would be the same question for relationships.

Thanks

As the issue reporter also contacted me by email, I'll paste part of my response below

Right now the best way to modify the node or relation is to query them (by using QueryNode or QueryRelation on the Database connection), modify it's values and then replace it inside the Database class.
However it would certainly require source code modification.

If I find the time, I will implement complete CRUD operations on nodes and relations by Sunday (01.05.2022)

The work on SliccDb will intensify shortly because I will be resuming work on a project that uses it as dependency.
Kind Regards,
Piotr

Hello again. I've added methods for Updating/Deleting Relations and Nodes.
Also, the Query API was simplified

var queryToDelete = Connection.Nodes().Properties("Name".Value("Tom")).Labels("Person").FirstOrDefault();

If you want to get all relations named "Person"

Connection.Relations("Person")

Here are examples (taken from Unit Tests)

Nodes

var node = Connection.Nodes().Properties("Name".Value("Steve")).First();
node.Properties["Name"] = "Steve2";
Connection.Update(node);

Relations

var relation = Connection.Relations("Likes").ToList().First();
relation.Properties["How Much"] = "Not So Much";
relation.Labels.Add("Love Hate Relationship");
Connection.Update(relation);