Overview Defining a Model Instances Creating Nodes and Relationships Merging Nodes and Relationships Updating Nodes and Relationships Deleting Nodes Deleting Relationships Finding Nodes and Relationships Hooks Temporary Databases
The QueryRunner
class also provides some helpers for custom Cypher queries.
The properties of nodes can be easily fetched
1linkconst queryResult = await queryRunner.run(
2link `MATCH (n:User {id: $id}) RETURN n`,
3link { id: 1 },
4link);
5link
6link/* --> get the properties of the node with the alias 'n' */
7linkconst properties = QueryRunner.getResultProperties(queryResult, 'n');
8linkconsole.log(properties[0].id); // 1
1linkconst res = await queryRunner.delete({
2link where: {
3link name: 'John'
4link },
5link});
6link
7linkconst nodesDeleted = QueryRunner.getNodesDeleted(res);
8linkconsole.log(nodesDeleted); // 5
QueryRunner
exposes the default identifiers which are used in the queries.
1link/* --> general purpose default identifier */
2linkconsole.log(QueryRunner.identifiers.default);
3link/* --> default identifiers for createRelationship */
4linkconsole.log(QueryRunner.createRelationship);
5link/* default identifier for the source node */
6linkconsole.log(QueryRunner.createRelationship.source);
7link/* default identifier for the target node */
8linkconsole.log(QueryRunner.createRelationship.target);