A dead-simple client for neo4j in Javascript.
Database constructor.
Name | Type | Description | |
---|---|---|---|
options |
Object
|
DB options. |
|
options.conn |
Object
|
Connection options (uri: |
|
options.maxSessionCount |
Integer
|
Maximum in-parallel sessions running inside the DB instance. |
|
options.maxWaitingCount |
Integer
|
Maximum requests waiting in queue to acquire session. |
const db = new Neo4JDB({conn: {uri: 'bolt://localhost:7474', username: 'neo4j', password: 'neo4j'}}).connect();
DB
Defines a model in database.
Name | Type | Description | |
---|---|---|---|
name |
String
|
Name of model as marked in DB. |
|
schema |
Schema
|
The data schema such model should be compliant with. |
const Neo4j = require('neo4j-schema');
let person = Neo4j.model(
'person',
Neo4j.Schema({
name: String,
age: Number,
group: [String]
})
);
Model
The Query constructor used for building queries. This could be instantiated by calling Model behavioural functions such as Model.match()
.
Name | Type | Description | |
---|---|---|---|
callee |
DB
Session
|
The callee to run such query when it's been constructed. |
|
model |
Function.<Model>
|
The model of which such query should be constrained to. |
|
opts |
Object
|
Void
Match clause.
Name | Type | Description | |
---|---|---|---|
patterns |
Array.<Pattern>
Array.<String>
|
match('patternStr' | {label: 'str', variable: 'n'});
Query
Basic relation clause, also known as --
.
Name | Type | Description | |
---|---|---|---|
pattern |
Object.<Pattern>
String
|
Query
Directed relation clause, also known as -->
.
Name | Type | Description | |
---|---|---|---|
pattern |
Object.<Pattern>
String
|
Query
Reverse directed relation clause, also known as <--
.
Name | Type | Description | |
---|---|---|---|
pattern |
Object.<Pattern>
String
|
Query
The node such query should point to.
Name | Type | Description | |
---|---|---|---|
pattern |
Object.<Pattern>
String
|
Query
Where clause.
Name | Type | Description | |
---|---|---|---|
filters |
Object.<Filters>
|
A filters map object that bears exactly the same APIs as in MongoDB. |
|
options |
.where({
user: {
name: {
$in: ['Tom', 'Jack', 'House']
},
age: {
$gte: 20,
$lte: 40
}
}
})
Query
Order By clause.
Name | Type | Description | |
---|---|---|---|
params |
Object
|
Sort the matched documents by properties. |
.orderBy({
name: 1 // sort by field "name" in alphanumeric order
age: -1 // and then sort by field "age" in descendant order.
})
Query
Delete clause.
Name | Type | Description | |
---|---|---|---|
vars |
Array.<String>
|
Variable names of nodes/relationships to delete from database. |
|
opts |
Object
|
||
opts.isDetach |
Boolean
|
Decide if the matched instances should also remove all existing relationships during their deletion. |
Query
Detach Delete clause. This method is equivalent to delete(vars, {isDetach: true}).
Name | Type | Description | |
---|---|---|---|
vars |
Array.<String>
|
Variable names of nodes/relationships to delete from database. |
Query
Remove clause.
Name | Type | Description | |
---|---|---|---|
pattern |
Object.<Pattern>
String
|
Query
Remove property of matched instance.
Name | Type | Description | |
---|---|---|---|
variable |
String
|
Variable name. |
|
property |
String
|
Property name. |
Query
With clause.
Name | Type | Description | |
---|---|---|---|
fields |
Array.<String>
|
The fields to carry over explicitly in a query. |
Query
Return clause.
Name | Type | Description | |
---|---|---|---|
fields |
Array.<String>
|
The fields to return in a query. |
Query
Create clause.
Name | Type | Description | |
---|---|---|---|
pattern |
Object.<Pattern>
String
|
The pattern specifying which instance to create. |
Query
Bulk creation clause.
Name | Type | Description | |
---|---|---|---|
patterns |
Object.<Pattern>
String
|
The patterns to create in a single query. |
Query
Merge clause.
Name | Type | Description | |
---|---|---|---|
pattern |
Object.<Pattern>
String
|
The pattern specifying which instance to merge (update or create). |
Query
Set clause.
Name | Type | Description | |
---|---|---|---|
pattern |
Object.<Pattern>
String
|
The pattern specifying which instance to update. |
|
upSert |
Boolean
|
Decide if the properties of node matched should be created if doesn't exist. |
Query
Name | Type | Description | |
---|---|---|---|
args |
Object
String
|
||
args.variable |
String
|
Variable name. |
|
args.label |
String
Array.<String>
|
Label(s) of node. |
|
args.props |
Object
|
Node properties map. |
|
alphabet |
Function.<String>
|
Generate alphabet series. |
Void
Transpile lean object to Joi schema.
Name | Type | Description | |
---|---|---|---|
obj |
Object
|
{
id: {type: String, required: true},
group: {type: String, default: 'User', enum: ['Admin', 'User']},
age: {type: Number},
createdAt: {type: Date, default: Date.now}
}
JoiSchema
Return a model function.
Name | Type | Description | |
---|---|---|---|
db |
DB
|
The DB instance such model should inherit from. |
Model
The compiled model function.
Return a model function.
Name | Type | Description | |
---|---|---|---|
db | |||
methods |
Model