%% Update Labels and Properties for Two Nodes
% Create two nodes in a Neo4j® database, update their node labels and properties, and display the labels and properties for the first node.
% Assume that you have graph data stored in a Neo4j database that represents a social neighborhood. This database has seven nodes and eight relationships. Each node has only one unique property key name with a value ranging from User1 through User7. Each relationship has the type knows.
%
% Create a Neo4j database connection using the URL http://localhost:7474/db/data, user name neo4j, and password matlab.

url = 'http://localhost:7474/db/data';
username = 'neo4j';
password = 'matlab';

neo4jconn = neo4j(url,username,password);

%
% Check the Message property of the Neo4j connection object neo4jconn. The blank Message property indicates a successful connection.

neo4jconn.Message

%
% Create two nodes in the database using the Neo4j database connection. These nodes represent two people.

user8 = createNode(neo4jconn);
user9 = createNode(neo4jconn);

%
% Create a table with two rows. Each row contains data about a person. Specify the name and job title for each person.

properties = table(["User8";"User9"],["Analyst";"Technician"], ...
    'VariableNames',{'Name','Title'});

%
% Update the nodes by adding the labels Person and Employee and the node properties defined in the table.

labels = ["Person","Employee"];
updateNode(neo4jconn,[user8;user9],'Labels',labels, ...
    'Properties',properties)

%
% Display the node labels for the nodes.

nodeid = [user8.NodeID user9.NodeID];
nodeinfo = searchNodeByID(neo4jconn,nodeid);
nodeinfo.NodeLabels{:}

%
% Display the node properties for the nodes.

nodeinfo.NodeData{:}

%
% Close the database connection.

close(neo4jconn)

% Copyright 2018 The MathWorks, Inc.