@iammhc/nestjs-neo4j
v1.0.1
Published
Neo4j driver for Nest Framework.
Downloads
15
Maintainers
Readme
Neo4j for NestJS
Neo4j driver for Nest Framework.
What's New
Installation
$ npm i --save @iammhc/nestjs-neo4j
or
$ yarn add @iammhc/nestjs-neo4j
Usage
import { Neo4jModule, Neo4jModuleConfig } from '@iammhc/nestjs-neo4j';
Configuration
imports: [
Neo4jModule.forRoot({
host: 'localhost',
password: '',
port: 34498,
scheme: 'bolt',
username: 'neo4j',
}),
],
Async Configuration
When you need to set Neo4jModule
options asynchronously instead of statically, use the forRootAsync()
method. As with most dynamic modules, Nest provides several techniques to deal with async configuration.
One technique is to use a factory function:
Like other factory providers, our factory function can be async
and can inject dependencies through inject
.
imports: [
Neo4jModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService): Neo4jModuleConfig => ({
host: configService.get('NEO4J_HOST'),
password: configService.get('NEO4J_PASSWORD'),
port: configService.get('NEO4J_PORT'),
scheme: configService.get('NEO4J_SCHEME'),
username: configService.get('NEO4J_USERNAME'),
}),
}),
],
Usage examples
import { Neo4jService } from '@iammhc/nestjs-neo4j';
constructor(private readonly neo4jService: Neo4jService) {}
example():Neo4jModuleConfig {
return this.neo4jService.getConfig();
}
| function | Description | Argument |
| --------------------- | -------------------------- | -------------------------------------- |
| getConfig
| Config Detail of neo4j | None |
| getDriver
| Neo4j Driver | None |
| getReadSession
| Get Read Session of Neo4j | getReadSession('database?')
|
| getWriteSession
| Get Write Session of Neo4j | getWriteSession('database?')
|
| read
| Use for Read Data | read('cypher','params','database?')
|
| write
| Use for write Data | write('cypher','params','database?')
|
Stay in touch
- Author - Hashir Ch
- Website - https://iammhc.com
- Twitter - @IamMHC
License
Package is MIT licensed.