Static Member Summary
| Static Public Members | ||
| public static get |
Collection: * |
|
| public static get |
baseLabel: * |
|
| public static get |
labels: * |
|
| public static get |
queryDefaults: {"parameters": *, "variable": string, "variables": *, "links": *} Default values for query options |
|
| public static get |
Definitions of the relationships for this Node |
|
Static Method Summary
| Static Public Methods | ||
| public static |
|
|
| public static |
|
|
| public static |
async all(o: QueryOptions): NodeCollection Fetch Nodes |
|
| public static |
buildQuery(o: object): string Build a search query |
|
| public static |
async count(filters: object | string, parameters: any, o: QueryOptions): number Count nodes in graph database |
|
| public static |
async dropIndex(property: *) |
|
| public static |
async dropUnique(property: *) |
|
| public static |
async find(filters: object | string | number, o: QueryOptions): NodeCollection Find Nodes based on filter or Node ID |
|
| public static |
async get(filters: string | object, o: QueryOptions): Node Fetch a single Node |
|
| public static |
getRelationship(name: string): Relationship Get a Relationship class by name. |
|
| public static |
getRelationshipQueryOptions(levels: string, variables: object, reference: string): options Build query options for related nodes Mostly intended for internal usage. |
|
| public static |
async merge(criteria: object, properties: object, o: QueryOptions): Node Get a node or a create a new one based on the given properties |
|
| public static |
normalizeRelationshipLevels(levels: *): * |
|
| public static |
parseQueryFilters(filters: object | string | number, variable: string): QueryOptions Parse search filters |
|
| public static |
async query(query: string, parameters: object, o: QueryOptions): NodeCollection Use a query statement to search for Nodes By default returns results for 'n' as Node collection |
|
| public static |
ID generator, uses ShortId by default |
|
| public static |
async where(where: string, parameters: object, o: QueryOptions): NodeCollection Use a query statement to search for Nodes By default returns results for 'n' as Node collection |
|
Constructor Summary
| Public Constructor | ||
| public |
constructor(node: Node | neo4j.types.Node, graph: Graph) Creates an instance of Node. |
|
Member Summary
| Public Members | ||
| public get |
$base: * |
|
| public get |
Whether or not the Node has changed properties. |
|
| public |
$entity: neo4.Node |
|
| public |
|
|
| public get |
The neo4j entity ID. |
|
| public get |
Node labels. |
|
| public set |
Node labels. |
|
| public get |
Whether or not the node is already stored in the graph database. |
|
| public get |
The node ID. |
|
| public set |
|
|
Method Summary
| Public Methods | ||
| public |
|
|
| public |
|
|
| public |
addRelated(name: string, node: Node | NodeCollection | Node[], properties: Object) Add related node(s). |
|
| public |
clearCachedRelationships(relationships: undefined) |
|
| public |
Delete node from the graph database |
|
| public |
async deleteRelated(tx: Transaction) Delete related nodes and their relationships |
|
| public |
async fetchRelated(relationships: object | array | string): NodeCollection | Object<string, NodeCollection> Fetch related Nodes connected to the current node. |
|
| public |
Get a Node property or related node(s). |
|
| public |
Get linked results. |
|
| public |
getRelated(name: string): RelatedNodeCollection Get related node(s). |
|
| public |
getRelationship(name: string): Relationship Get a Relationship class by name. |
|
| public |
has(key: *): * |
|
| public |
async removeLabel(label: *, tx: undefined) |
|
| public |
async removeLabels(labels: *, tx: undefined) |
|
| public |
Save the Node to the graph database. |
|
| public |
async saveRelated(keys: Array, tx: Transaction) Save related nodes and their relationships |
|
| public |
Set a Node property or related node(s). |
|
| public |
setProperty(key: string, value: any) Set property value |
|
| public |
setRelated(name: string, node: Node | NodeCollection | Node[], properties: any, overwrite: boolean) Set related node(s). |
|
Static Public Members
public static get Collection: * source
public static get baseLabel: * source
public static get labels: * source
public static get queryDefaults: {"parameters": *, "variable": string, "variables": *, "links": *} source
Default values for query options
public static get relationships: object<string, RelationshipDefinition> source
Definitions of the relationships for this Node
Static Public Methods
public static addIndex(property: *, now: boolean): * source
Params:
| Name | Type | Attribute | Description |
| property | * | ||
| now | boolean |
|
Return:
| * |
public static addUnique(property: *, now: boolean): * source
Params:
| Name | Type | Attribute | Description |
| property | * | ||
| now | boolean |
|
Return:
| * |
public static async all(o: QueryOptions): NodeCollection source
Fetch Nodes
Params:
| Name | Type | Attribute | Description |
| o | QueryOptions | Query options |
Example:
const nodes = await Node.all({ limit: 10 })
public static buildQuery(o: object): string source
Build a search query
Params:
| Name | Type | Attribute | Description |
| o | object | Query options |
public static async count(filters: object | string, parameters: any, o: QueryOptions): number source
Count nodes in graph database
Params:
| Name | Type | Attribute | Description |
| filters | object | string | Search filters (object) or where clause (string) |
|
| parameters | any |
|
Parameters used in where clause |
| o | QueryOptions |
|
Query options |
public static async dropIndex(property: *) source
Params:
| Name | Type | Attribute | Description |
| property | * |
public static async dropUnique(property: *) source
Params:
| Name | Type | Attribute | Description |
| property | * |
public static async find(filters: object | string | number, o: QueryOptions): NodeCollection source
Find Nodes based on filter or Node ID
Params:
| Name | Type | Attribute | Description |
| filters | object | string | number | Search filters, Node ID (string), or neo4j node identifier (number) |
|
| o | QueryOptions |
|
Query options |
Example:
// Find by ID
const nodes = Node.find('foo')
// Find by filter
const nodes = Node.find({ foo: 1 })
// Find by filter, with related Nodes
const nodes = Node.find({ foo: 1 }, { with: 'relatives' })
nodes[0].relatives
public static async get(filters: string | object, o: QueryOptions): Node source
Fetch a single Node
Params:
| Name | Type | Attribute | Description |
| filters | string | object | Filter object or Node id |
|
| o | QueryOptions |
|
Query options |
Example:
const node = await Node.get('foo')
const node = await Node.get({ id: 'foo' })
public static getRelationship(name: string): Relationship source
Get a Relationship class by name.
Params:
| Name | Type | Attribute | Description |
| name | string | The name of the relationship |
public static getRelationshipQueryOptions(levels: string, variables: object, reference: string): options source
Build query options for related nodes Mostly intended for internal usage.
Params:
| Name | Type | Attribute | Description |
| levels | string | Filter for related nodes in dot-format (eg. father.children will fetch the related 'father' and its 'children') |
|
| variables | object | The variables currently used for building the query |
|
| reference | string |
|
Reference variable for the current node |
Return:
| options | Query options object |
Return Properties:
| Name | Type | Attribute | Description |
| matches | array | Optional matches for each relationship |
|
| variables | object | The variables currently used for building the query |
public static async merge(criteria: object, properties: object, o: QueryOptions): Node source
Get a node or a create a new one based on the given properties
Params:
| Name | Type | Attribute | Description |
| criteria | object | Specific properties to match |
|
| properties | object | Properties to be set on the existing or created node |
|
| o | QueryOptions |
|
Query options |
public static normalizeRelationshipLevels(levels: *): * source
Params:
| Name | Type | Attribute | Description |
| levels | * |
Return:
| * |
public static parseQueryFilters(filters: object | string | number, variable: string): QueryOptions source
Parse search filters
public static async query(query: string, parameters: object, o: QueryOptions): NodeCollection source
Use a query statement to search for Nodes By default returns results for 'n' as Node collection
Params:
| Name | Type | Attribute | Description |
| query | string | A search query |
|
| parameters | object |
|
Parameters used in query |
| o | QueryOptions |
|
Query options |
Example:
const nodes = await Node.query(`
MATCH (n:Node)
WHERE n.foo > {foo}
`, { foo: 1 })
public static async where(where: string, parameters: object, o: QueryOptions): NodeCollection source
Use a query statement to search for Nodes By default returns results for 'n' as Node collection
Params:
| Name | Type | Attribute | Description |
| where | string | A where clause |
|
| parameters | object |
|
Parameters used in query |
| o | QueryOptions |
|
Query options |
Example:
const nodes = await Node.where('n.foo > {foo}', { foo: 1 })
Public Constructors
Public Members
public get $base: * source
public $entity: neo4.Node source
public get $id: number source
The neo4j entity ID. Note that this could change over time, use id instead.
public get $labels: Array source
Node labels. Will be added the node in the graph database. By default it uses the constructor name.
public set $labels(labels: Array): Array source
Node labels. Will be added the node in the graph database. By default it uses the constructor name.
public get id: string source
The node ID. This will be automatically generated when the node is saved
public set id source
Public Methods
public async addLabel(label: *, tx: undefined) source
Params:
| Name | Type | Attribute | Description |
| label | * | ||
| tx | undefined |
|
public async addLabels(labels: *, tx: undefined) source
Params:
| Name | Type | Attribute | Description |
| labels | * | ||
| tx | undefined |
|
public addRelated(name: string, node: Node | NodeCollection | Node[], properties: Object) source
Add related node(s). Existing nodes will not be overwritten unless the relationship is singular.
Params:
| Name | Type | Attribute | Description |
| name | string | The name of the relationship |
|
| node | Node | NodeCollection | Node[] | Node(s) |
|
| properties | Object |
|
Properties to set on the relationship(s) |
public clearCachedRelationships(relationships: undefined) source
Params:
| Name | Type | Attribute | Description |
| relationships | undefined |
|
public async delete(deep: boolean, tx: Transaction) source
Delete node from the graph database
Params:
| Name | Type | Attribute | Description |
| deep | boolean |
|
Delete related nodes |
| tx | Transaction |
|
The current database transaction |
public async deleteRelated(tx: Transaction) source
Delete related nodes and their relationships
Params:
| Name | Type | Attribute | Description |
| tx | Transaction |
|
The current database transaction |
public async fetchRelated(relationships: object | array | string): NodeCollection | Object<string, NodeCollection> source
Fetch related Nodes connected to the current node.
public get(key: string): any | RelatedNodeCollection source
Get a Node property or related node(s).
Params:
| Name | Type | Attribute | Description |
| key | string | The name of the property or relationship |
Return:
| any | RelatedNodeCollection | The value or related node(s) |
public getLinked(name: string): * source
Get linked results.
Params:
| Name | Type | Attribute | Description |
| name | string | The name of the link |
Return:
| * | The related node(s) / value(s) or null if none is found |
public getRelated(name: string): RelatedNodeCollection source
Get related node(s).
Params:
| Name | Type | Attribute | Description |
| name | string | The name of the relationship |
Return:
| RelatedNodeCollection | The related node(s) |
public getRelationship(name: string): Relationship source
Get a Relationship class by name.
Params:
| Name | Type | Attribute | Description |
| name | string | The name of the relationship |
public async removeLabel(label: *, tx: undefined) source
Params:
| Name | Type | Attribute | Description |
| label | * | ||
| tx | undefined |
|
public async removeLabels(labels: *, tx: undefined) source
Params:
| Name | Type | Attribute | Description |
| labels | * | ||
| tx | undefined |
|
public async saveRelated(keys: Array, tx: Transaction) source
Save related nodes and their relationships
Params:
| Name | Type | Attribute | Description |
| keys | Array |
|
The relationships to be saved (all by default) |
| tx | Transaction |
|
The current database transaction |
public set(key: string, value: any): boolean source
Set a Node property or related node(s).
Params:
| Name | Type | Attribute | Description |
| key | string | The name of the property or relationship |
|
| value | any | The value or related node(s) |
public setProperty(key: string, value: any) source
Set property value
Params:
| Name | Type | Attribute | Description |
| key | string | Property name |
|
| value | any | Property value |
public setRelated(name: string, node: Node | NodeCollection | Node[], properties: any, overwrite: boolean) source
Set related node(s).
Params:
| Name | Type | Attribute | Description |
| name | string | The name of the relationship |
|
| node | Node | NodeCollection | Node[] | Node(s) |
|
| properties | any |
|
Properties to set on the relationship(s) |
| overwrite | boolean |
|
If set to false existing nodes will not be overwritten unless the relationship is singular |
