setNodeProperty
Set properties for nodes in Neo4j database
Syntax
Description
setNodeProperty(
sets properties for one or more nodes in a Neo4j® database using a Neo4j database connection.neo4jconn
,node
,properties
)
Examples
Set One Node Property
Set one node property for a single node in a Neo4j® database and access the node.
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
ans = []
Retrieve the first node in the table of node information. This node has the label Person
.
nlabel = "Person";
nodeinfo = searchNode(neo4jconn,nlabel);
node = nodeinfo.NodeObject(1);
Set the Title
node property for a single node in the database using the Neo4j database connection.
properties.Title = "Analyst";
setNodeProperty(neo4jconn,node,properties)
Display the node information for the updated node.
nodeinfo = searchNode(neo4jconn,nlabel); node = nodeinfo.NodeObject(1); node.NodeData
ans = struct with fields:
name: 'User1'
Title: 'Analyst'
Close the database connection.
close(neo4jconn)
Set Multiple Node Properties and Return Output
Set node properties for multiple nodes in a Neo4j® database. Access the updated node 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
ans = []
Find nodes with the label Person
, and select the first two nodes.
nlabel = "Person";
nodeinfo = searchNode(neo4jconn,nlabel);
nodes = nodeinfo.NodeObject;
firstnodes = nodes(1:2);
Set the Title
node property for multiple nodes to different values using the Neo4j database connection. Create a structure array to store the properties. Display the updated node information for the first two nodes. The nodeinfo
output argument is a Neo4jNode
object.
properties(1).Title = "Analyst"; properties(2).Title = "Engineer"; nodeinfo = setNodeProperty(neo4jconn,firstnodes,properties); nodeinfo.NodeData{1:2}
ans = struct with fields:
name: 'User1'
Title: 'Analyst'
ans = struct with fields:
name: 'User3'
Title: 'Engineer'
Close the database connection.
close(neo4jconn)
Input Arguments
neo4jconn
— Neo4j database connection
Neo4jConnect
object
Neo4j database connection, specified as a Neo4jConnect
object created with the function neo4j
.
node
— Node
Neo4jNode
object | Neo4jNode
object array | numeric scalar | numeric vector
Node in a Neo4j database, specified as a Neo4jNode
object, Neo4jNode
object array, numeric scalar,
or a numeric vector. For one node, specify a Neo4jNode
object or a
numeric scalar. For multiple nodes, specify a Neo4jNode
object array or
a numeric vector.
The numeric scalar or vector must contain Neo4j database node identifiers.
Example: 15
Example: [2,3,4]
properties
— Node properties
structure | structure array | table
Node properties, specified as a structure, structure array, or table.
If a property does not exist, then the setNodeProperty
function
adds a new property. If the property exists, then the function sets a new value for the
existing property.
When you specify a structure, the setNodeProperty
function
converts each field and its corresponding value to a property and its corresponding
value in the database node. When you specify a table that contains one row, the function
converts each variable and its corresponding value to a property and its corresponding
value in the database node.
Specify a structure array or a table with multiple rows to update multiple nodes in the database.
The dimensions of the data in the structure array or table must be the same as the number of the specified nodes in the database to update. However, you can use a scalar structure to set the same values for multiple nodes in the database simultaneously.
Data Types: struct
| table
Output Arguments
nodeinfo
— Node information
Neo4jNode
object | table
Node information in the Neo4j database, returned as a Neo4jNode
object for one node or as a table for multiple nodes.
For multiple nodes, the table contains these variables:
NodeLabels
— Cell array of character vectors that contains the node labels for each database nodeNodeData
— Cell array of structures that contains node information such as property keysNodeObject
—Neo4jNode
object for each database node
The row names of the table are Neo4j node identifiers of each database node.
Version History
Introduced in R2019a
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)