Creating a basic node with label using user defined procedure

The neo4j doc state that we can perform write operations on DB by User Defined Procedures using mode=mode.WRITE with this I have successfully implemented delete operation but for creating a node there is no sample document and I am finding it difficult to implement so is there any sample snippet for that?

You can use createNode api.

public static final Label                      EVENT_NODE_LABEL                = Label

Node eventNode = db.createNode(EVENT_NODE_LABEL);
                eventNode.setProperty("timestamp", timestamp);
                eventNode.setProperty("status", "NEW");

That's it.

1 Like

something like this creates a node and sets a propery called property to an int value:
public class Insert {

public Transaction tx;                                                                                            

public Log log;                                                                                                   

@Procedure(name = "test.create", mode = Mode.WRITE)
@Description("CALL test.create(label, long_prop)")
public void create(@Name(value = "label") String label,
                                @Name(value = "prop") Long prop){
    Label l = Label.label(label);                                                                                 
    Node node = tx.createNode(l);                                                                                 
  	node.setProperty("property", prop);                                                                           


1 Like