Star

Created With

linkCreating Relationships

A QueryRunner instance can be used for creating relationships from Objects. Information and where parameters about the source and target nodes can be used.

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

2linkconst result = await queryRunner.createRelationship({

3link source: {

4link /* --> (optional) the label of the source Node to be matched --> */

5link label: 'Users',

6link /* --> (optional) the identifier of the source Node th be used in the query. Defaults to the value of 'QueryRunner.identifiers.createRelationship.source' */

7link identifier: 'source'

8link },

9link target: {

10link /* --> (optional) the label of the target Node to be matched --> */

11link label: 'Orders',

12link /* --> (optional) the identifier of the source Node th be used in the query. Defaults to the value of 'QueryRunner.identifiers.createRelationship.target' */

13link identifier: 'target'

14link },

15link relationship: {

16link /* --> the name of the relationship */

17link name: 'CREATES',

18link /* --> the direction of this relationship, between source and target. Valid values are 'in', 'out', 'none' */

19link direction: 'out',

20link /* --> (optional) properties of the relationship */

21link properties: {

22link rating: 4

23link }

24link },

25link /* --> (optional) the where clause for the source and target nodes to be matched. A param object or a Where instance can be used. The source/target identifiers needs to be used as keys */

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

27link /* --> where params for the source Node. The source identifier needs to be used as a key */

28link source: {

29link id: {

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

31link [Op.in]: ['1', '2']

32link }

33link },

34link /* --> where params for the target Node. The target identifier needs to be used as a key */

35link target: {

36link name: 'Bob'

37link },

38link },

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

40link session: null,

41link});

42link

43link/* --> the result is the QueryResult from the neo4j driver */

44linkconsole.log(result);

Creating Relationships

Introduction Getting Started

Modelschevron_right

Sessions and Transactions

Query Builderchevron_right
Query Runnerchevron_right

Bind Parameters

Where Parameters