%% Set Multiple Relationship Properties and Return Output
% Set relationship properties for multiple relationships in a Neo4j® database. Access the updated relationship information using an output argument.
%
% 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

%
% Find the origin node with the node identifier 3 and retrieve its node information.

nodeid = 3;
nodeinfo = searchNodeByID(neo4jconn,nodeid);

%
% Find the outgoing relationships from the origin node.

direction = "out";
relinfo = searchRelation(neo4jconn,nodeinfo,direction);
relation = relinfo.Relations.RelationObject;

%
% Set the MeetLocation property for two outgoing relationships to different values using the Neo4j database connection. Create a structure array to store the properties. The relationinfo output argument is a Neo4jRelation object.

properties(1).MeetLocation = "Chicago";
properties(2).MeetLocation = "Miami";
relationinfo = setRelationProperty(neo4jconn,relation,properties);

%
% Display the relationship information for the two updated relationships.

relationinfo.RelationData{1:2}

%
% Close the database connection.

close(neo4jconn)

% Copyright 2018 The MathWorks, Inc.