Main Content

removeNodeProperty

Remove properties from nodes inNeo4jdatabase

描述

example

removeNodeProperty(neo4jconn,node,propertyNames)removes properties from one or more nodes in a Neo4j®database using a Neo4j database connection.

example

nodeinfo= removeNodeProperty(neo4jconn,node,propertyNames)returns updated node information as aNeo4jNodeobject for one node, or as a table for multiple nodes.

Examples

collapse all

Remove one node property from a single node in a Neo4j® database and access the node.

Create a Neo4j database connection using the URLhttp://localhost:7474/db/data, user nameneo4j, and passwordmatlab.

url ='http://localhost:7474/db/data'; username ='neo4j'; password ='matlab'; neo4jconn = neo4j(url,username,password);

Check theMessageproperty of the Neo4j connection objectneo4jconn. The blankMessageproperty indicates a successful connection.

neo4jconn.Message
ans = []

Retrieve the first node in the table of node information. This node has the labelPerson.

nlabel ="Person"; nodeinfo = searchNode(neo4jconn,nlabel); node = nodeinfo.NodeObject(1);

Set theTitlenode 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'

Remove the node property.

propertyNames ="Title"; removeNodeProperty(neo4jconn,node,propertyNames)

Display the node information for the updated node.

nodeinfo = searchNode(neo4jconn,nlabel); node = nodeinfo.NodeObject(1); node.NodeData
ans =struct with fields:name: 'User1'

Close the database connection.

close(neo4jconn)

Remove node properties from multiple nodes in a Neo4j® database. Access the updated node information using an output argument.

Create a Neo4j database connection using the URLhttp://localhost:7474/db/data, user nameneo4j, and passwordmatlab.

url ='http://localhost:7474/db/data'; username ='neo4j'; password ='matlab'; neo4jconn = neo4j(url,username,password);

Check theMessageproperty of the Neo4j connection objectneo4jconn. The blankMessageproperty indicates a successful connection.

neo4jconn.Message
ans = []

Find nodes with the labelPerson.

nlabel ="Person"; nodeinfo = searchNode(neo4jconn,nlabel); nodes = nodeinfo.NodeObject;

Set theTitleandDepartmentnode properties for multiple nodes using the Neo4j database connection. Display the updated node information for the first three nodes.

properties.Title ="Analyst"; properties.Department ="Sales"; nodeinfo = setNodeProperty(neo4jconn,nodes,properties); nodeinfo.NodeData{1:3}
ans =struct with fields:Department: 'Sales' name: 'User1' Title: 'Analyst'
ans =struct with fields:Department: 'Sales' name: 'User3' Title: 'Analyst'
ans =struct with fields:Department: 'Sales' name: 'User2' Title: 'Analyst'

Remove the node properties using the property names. Display the updated node information for the first three nodes. Thenodeinfooutput argument is aNeo4jNodeobject.

propertyNames = ["Title""Department"]; nodeinfo = removeNodeProperty(neo4jconn,nodes,propertyNames); nodeinfo.NodeData{1:3}
ans =struct with fields:name: 'User1'
ans =struct with fields:name: 'User3'
ans =struct with fields:name: 'User2'

Close the database connection.

close(neo4jconn)

Input Arguments

collapse all

Neo4j database connection, specified as aNeo4jConnectobject created with the functionneo4j.

Node in a Neo4j database, specified as aNeo4jNodeobject,Neo4jNodeobject array, numeric scalar, or a numeric vector. For one node, specify aNeo4jNodeobject or a numeric scalar. For multiple nodes, specify aNeo4jNodeobject array or a numeric vector.

The numeric scalar or vector must contain Neo4j database node identifiers.

Example:15

Example:[2,3,4]

Property names, specified as a character vector, cell array of character vectors, string scalar, or string array. For one property, use a character vector or string scalar. For multiple properties, use a cell array of character vectors or a string array.

Example:"Analyst"

Example:["Analyst" "Clerk"]

Data Types:char|string

Output Arguments

collapse all

Node information in the Neo4j database, returned as aNeo4jNodeobject 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 node

  • NodeDatath -单元阵列的结构at contains node information such as property keys

  • NodeObjectNeo4jNodeobject for each database node

The row names of the table are Neo4j node identifiers of each database node.

Introduced in R2019a