Home Reference Source
import Graph from 'neo-maggoo/lib/Graph.js'
public class | source

Graph

Object-Graph Map

Static Member Summary

Static Public Members
public static get

Node: *

public static get
public static get
public static get
public static get
public static get
public static get
public static get

db: *

Get a database instance.

Static Method Summary

Static Public Methods
public static

build(query: string, parameters: object, models: object, links: object): Graph

Build a graph from query results.

public static

getEntity(subject: Node | neo4j.types.Node | Object): neo4j.types.Node

Get the Neo4j node entity

public static

getId(subject: Node | neo4j.types.Node | Object): Number

Get Neo4j Node id

public static

typeOf(entity: any): string

Get the type of the entity

Constructor Summary

Public Constructor
public

constructor(result: neo4j.Result, models: object, links: object)

Creates an instance of Graph.

Member Summary

Public Members
public

index: *

public

links: *

public

models: *

public

nodes: *

public
public

Method Summary

Public Methods
public

add(entity: neo4j.types.Node | neo4j.types.Node[] | neo4j.types.Relationship | neo4j.types.Relationship[], key: string)

Add one or more entities to the graph

public

addLinks(record: neo4j.Record)

Link record items

public

addRecords(records: neo4j.Record[])

Add records to the graph

public

getLinked(node: Node, name: string): any

Get linked results mapped to Models

public

getMap(entity: any): Map

Get the map used for the entity

public

getNodeModel(id: Number | neo4j.integer, $Node: Function<Node>): Node

Wrap a Neo4j node in a specified Node model

public

getNodes(reference: string): array

Get all Nodes for a reference used in the Cypher query

public

getRelated(node: Node, $Relationship: Function): Node[]

Get related nodes

public

getRelationship(start: Node, end: Node, $Relationship: Function): Relationship

Get Relationship from the graph

public

remove(obj: neo4j.types.Node | neo4j.types.Node[] | neo4j.types.Relationship | neo4j.types.Relationship[] | Node | Node[] | Relationship | Relationship[])

Remove one or more entities from the graph

public

run(query: string, parameters: Object, models: Object, links: Object): Promise

Run a Cypher query and add the result to the current Graph instance

public

Static Public Members

public static get Node: * source

public static get NodeCollection: * source

public static get Relationship: * source

public static get TYPE_ARRAY: string source

public static get TYPE_INTEGER: string source

public static get TYPE_NODE: string source

public static get TYPE_RELATIONSHIP: string source

public static get db: * source

Get a database instance.

Static Public Methods

public static build(query: string, parameters: object, models: object, links: object): Graph source

Build a graph from query results. Map variables returned from the query to Nodes

Params:

NameTypeAttributeDescription
query string

The search query.

parameters object

The parameters used in the search query.

models object

variables and Node models as key-value pairs.

links object
  • optional
  • default: null

virtual relationships between records

Return:

Graph

The resulting graph.

public static getEntity(subject: Node | neo4j.types.Node | Object): neo4j.types.Node source

Get the Neo4j node entity

Params:

NameTypeAttributeDescription
subject Node | neo4j.types.Node | Object

Anything that could represent a node

Return:

neo4j.types.Node

The Neo4j Node entity

public static getId(subject: Node | neo4j.types.Node | Object): Number source

Get Neo4j Node id

Params:

NameTypeAttributeDescription
subject Node | neo4j.types.Node | Object

Anything that could represent a node

Return:

Number

The Neo4j Node ID as number

public static typeOf(entity: any): string source

Get the type of the entity

Params:

NameTypeAttributeDescription
entity any

Entity object

Return:

string

Graph.TYPE_NODE, Graph.TYPE_RELATIONSHIP, Graph.TYPE_INTEGER or native JS type

Public Constructors

public constructor(result: neo4j.Result, models: object, links: object) source

Creates an instance of Graph.

Params:

NameTypeAttributeDescription
result neo4j.Result

Result of a query.

models object

variables and Node models as key-value pairs.

links object
  • optional
  • default: null

virtual relationships between records

Public Members

public index: * source

public models: * source

public nodes: * source

public references: {} source

public relationships: * source

Public Methods

public add(entity: neo4j.types.Node | neo4j.types.Node[] | neo4j.types.Relationship | neo4j.types.Relationship[], key: string) source

Add one or more entities to the graph

Params:

NameTypeAttributeDescription
entity neo4j.types.Node | neo4j.types.Node[] | neo4j.types.Relationship | neo4j.types.Relationship[]

One or more entities

key string

The key associated with this

Link record items

Params:

NameTypeAttributeDescription
record neo4j.Record

Neo4j Record

public addRecords(records: neo4j.Record[]) source

Add records to the graph

Params:

NameTypeAttributeDescription
records neo4j.Record[]

Neo4j Records

public getLinked(node: Node, name: string): any source

Get linked results mapped to Models

Params:

NameTypeAttributeDescription
node Node

The start node

name string

The name of the link

Return:

any

The linked result

public getMap(entity: any): Map source

Get the map used for the entity

Params:

NameTypeAttributeDescription
entity any

Entity object

Return:

Map

The entity map

public getNodeModel(id: Number | neo4j.integer, $Node: Function<Node>): Node source

Wrap a Neo4j node in a specified Node model

Params:

NameTypeAttributeDescription
id Number | neo4j.integer

The Neo4j Node ID

$Node Function<Node>

The Node Model Class

Return:

Node

The Node model

public getNodes(reference: string): array source

Get all Nodes for a reference used in the Cypher query

Params:

NameTypeAttributeDescription
reference string

The reference

Return:

array

An array of nodes

public getRelated(node: Node, $Relationship: Function): Node[] source

Get related nodes

Params:

NameTypeAttributeDescription
node Node

Start node

$Relationship Function

Relationship class

Return:

Node[]

Related nodes

public getRelationship(start: Node, end: Node, $Relationship: Function): Relationship source

Get Relationship from the graph

Params:

NameTypeAttributeDescription
start Node

Start node

end Node

End node

$Relationship Function

Relationship class

Return:

Relationship

Relationship or null if no match was found

public remove(obj: neo4j.types.Node | neo4j.types.Node[] | neo4j.types.Relationship | neo4j.types.Relationship[] | Node | Node[] | Relationship | Relationship[]) source

Remove one or more entities from the graph

Params:

NameTypeAttributeDescription
obj neo4j.types.Node | neo4j.types.Node[] | neo4j.types.Relationship | neo4j.types.Relationship[] | Node | Node[] | Relationship | Relationship[]

One or more objects

public run(query: string, parameters: Object, models: Object, links: Object): Promise source

Run a Cypher query and add the result to the current Graph instance

Params:

NameTypeAttributeDescription
query string

A Cypher query

parameters Object

Parameters used in the query

models Object
  • optional

Map variables to Models

links Object
  • optional

Link results to a specific Model

Return:

Promise

A promise

public setRelationshipsIndex(entity: *) source

Params:

NameTypeAttributeDescription
entity *