Star

Created With
You are viewing the documentation for Neogma v1. This version is in maintenance mode, and you can upgrade to v2 following the migration guide. For the latest features and improvements, see the Neogma v2 documentation.

linkUpdating Nodes

A QueryRunner instance can be used for editing nodes from Objects. The node properties to update, a optional label, and an optional where param are needed.

1link/* --> let 'queryRunner' be a QueryRunner instance */

2linkconst result = await queryRunner.update({

3link /* --> the matched nodes will be updated with the following values */

4link data: {

5link name: 'Alex',

6link age: 30,

7link /* --> using the "remove" Symbol from "UpdateOp" */

8link disabled: { [UpdateOp.remove]: true },

9link },

10link /* --> (optional) label(s) of the nodes to be matched. Multiple labels like 'User:Person' can also be used */

11link label: 'User',

12link /* --> (optional) the where clause for the nodes to be matched. A param object or a Where instance can be used */

13link where: { // @see [Where](../Where-Parameters)

14link /* --> the identifier needs to be used as a key */

15link u: {

16link id: {

17link /* --> using the "in" Symbol from "Op" */

18link $[Op.in]: ['1', '2']

19link }

20link }

21link },

22link /* --> (optional) the identifier of the nodes for the query. Is needed for parsing the results. Default is the value of 'QueryRunner.identifiers.default' */

23link identifier: 'u',

24link /* --> (optional) whether to return the nodes */

25link return: true,

26link /* --> (optional) an existing session or transaction to use */

27link session: null,

28link});

29link

30link/* --> the result is the QueryResult from the neo4j driver. In case the nodes were returned, their properties can be retrieved */

31linkconsole.log(result.records.map((v) => v.get('u').properties));

linkUpdate Operators

Node properties can be updated just by setting a new value of the respective type. However, some update operations can only be performed using the exported UpdateOp variable.

linkRemove a Property

When this operation is set to true, the respective property will be completely removed from the node (similar to the JS delete operator).

1link// ...

2link data: {

3link name: 'Alex',

4link /* --> using the "remove" Symbol from "UpdateOp" */

5link age: { [UpdateOp.remove]: true },

6link },

7link // ...

8link identifier: 'u',

9link// ...

10link

11linkconsole.log(result.records.map((v) => v.get('u').properties.age)); // undefined

Updating NodesUpdate OperatorsRemove a Property

Introduction Getting Started

Modelschevron_right

Sessions and Transactions

Query Builderchevron_right
Query Runnerchevron_right

Bind Parameters

Where Parameters