prorm API Reference
    Preparing search index...

    Class Neo4jStore

    Neo4jStore wraps a neo4j-driver Driver and exposes:

    • raw parameterized Cypher (run()) - the general escape hatch,
    • session management (session()),
    • transaction functions with automatic retry (executeRead()/executeWrite()),
    • explicit begin/commit/rollback transactions (beginTransaction()),
    • and Cypher-generating node/relationship CRUD convenience helpers (createNode(), findNodes(), createRelationship(), etc) built on top of run() - these are thin Cypher generators, not a separate query engine, so anything they don't cover is one run() call away.

    Implements

    Index
    name: "neo4j" = 'neo4j'

    The name of the store (e.g. 'mongodb', 'redis', 'dynamodb')

    library: "neo4j-driver" = 'neo4j-driver'

    The client library being used

    • Open a new Session. Sessions are lightweight and disposable - open one per logical unit of work and close it when done (run(), executeRead()/executeWrite(), and beginTransaction() all do this for you; call this directly only if you need the raw Session, e.g. for session.run()'s streaming subscribe() API).

      Parameters

      Returns Session

    • Run a single parameterized Cypher statement as an auto-commit query, on a session opened and closed for just this call. Always parameterize user-supplied values ($name, not string concatenation) - the driver sends params separately from the query text, the same protection bind parameters give you against SQL injection.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      Returns Promise<CypherResult<T>>

    • Run work inside a managed read transaction. The driver automatically retries work on transient errors (e.g. deadlocks, leader switches in a cluster) - work may run more than once, so it must be idempotent and side-effect-free outside of the transaction it's given.

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

    • Like executeRead(), but for a managed write transaction (defaultAccessMode: 'WRITE').

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

    • Begin an explicit transaction spanning multiple run() calls, on a session held open until commit()/rollback(). Unlike executeRead()/executeWrite(), this is never retried automatically

      • use it when you need multiple round trips with logic in between, or full manual control over commit/rollback.

      Parameters

      Returns Promise<Neo4jTransaction>

    • CREATE (n:Label1:Label2) SET n = $properties RETURN n

      Type Parameters

      • P extends Record<string, unknown> = Record<string, unknown>

      Parameters

      • labels: string | string[]
      • properties: P = ...

      Returns Promise<GraphNode<P>>

    • MATCH (n) WHERE elementId(n) = $elementId RETURN n

      Type Parameters

      • P extends Record<string, unknown> = Record<string, unknown>

      Parameters

      • elementId: string

      Returns Promise<GraphNode<P> | null>

    • MATCH (n:Label) WHERE n.k1 = $k1 AND ... RETURN n [SKIP $skip] [LIMIT $limit]

      where is an equality-only match on node properties (no operators, ranges, or OR) - use run() directly for anything more expressive.

      Type Parameters

      • P extends Record<string, unknown> = Record<string, unknown>

      Parameters

      • labels: string | string[] = []
      • where: Record<string, unknown> = {}
      • options: Neo4jFindOptions = {}

      Returns Promise<GraphNode<P>[]>

    • MATCH (n) WHERE elementId(n) = $elementId SET n += $properties RETURN n (merges, does not replace, existing properties)

      Type Parameters

      • P extends Record<string, unknown> = Record<string, unknown>

      Parameters

      • elementId: string
      • properties: Partial<P>

      Returns Promise<GraphNode<P> | null>

    • MATCH (n) WHERE elementId(n) = $elementId [DETACH] DELETE n

      Without options.detach, deleting a node that still has relationships fails (Neo4j refuses to leave dangling relationships) - the underlying error surfaces as a DatabaseError. Returns whether a node was actually deleted (based on the query's nodesDeleted counter).

      Parameters

      Returns Promise<boolean>

    • MATCH (n:Label) WHERE ... RETURN count(n) AS count

      Parameters

      • labels: string | string[] = []
      • where: Record<string, unknown> = {}

      Returns Promise<number>

    • MATCH (a), (b) WHERE elementId(a) = $fromElementId AND elementId(b) = $toElementId CREATE (a)-[r:TYPE]->(b) SET r = $properties RETURN r

      Type Parameters

      • P extends Record<string, unknown> = Record<string, unknown>

      Parameters

      • fromElementId: string
      • toElementId: string
      • type: string
      • properties: P = ...

      Returns Promise<GraphRelationship<P>>

    • MATCH ()-[r]->() WHERE elementId(r) = $elementId RETURN r

      Type Parameters

      • P extends Record<string, unknown> = Record<string, unknown>

      Parameters

      • elementId: string

      Returns Promise<GraphRelationship<P> | null>

    • MATCH (a)-[r:TYPE]->(b) WHERE r.k1 = $k1 AND ... RETURN r [SKIP $skip] [LIMIT $limit]

      Omit type to match relationships of any type.

      Type Parameters

      • P extends Record<string, unknown> = Record<string, unknown>

      Parameters

      • Optionaltype: string
      • where: Record<string, unknown> = {}
      • options: Neo4jFindOptions = {}

      Returns Promise<GraphRelationship<P>[]>

    • MATCH (a)-[r]->(b) WHERE elementId(r) = $elementId DELETE r - returns whether a relationship was actually deleted.

      Parameters

      • elementId: string

      Returns Promise<boolean>