Skip to content

ipv6wiz/nest-neo4j

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nest Logo

Nest Neo4j

Neo4j integration for Nest

Description

This repository provides Neo4j integration for Nest.
Forked from Adam Cowley's project at https://www.npmjs.com/package/nest-neo4j
Cleaned up the dependencies, now builds without errors or warnings

Installation

$ npm i --save nest-neo4j-mmci

Quick Start

Register the Neo4j Module in your application using the forRoot method, passing the neo4j connection information as an object:

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { Neo4jModule } from 'nest-neo4j-mmci'

@Module({
  imports: [
    Neo4jModule.forRoot({
      scheme: 'neo4j',
      host: 'localhost',
      port: 7687,
      username: 'neo4j',
      password: 'neo'
    })
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

Querying Neo4j

The Neo4jService is @Injectable, so can be passed into any constructor:

import { Neo4jService } from 'nest-neo4j-mmci'

@Controller()
export class AppController {
  constructor(private readonly appService: AppService,
    private readonly neo4jService: Neo4jService
    ) {}

  @Get()
  async getHello(): Promise<any> {
    const res = await this.neo4jService.read(`MATCH (n) RETURN count(n) AS count`)

    return `There are ${res.records[0].get('count')} nodes in the database`
  }
}

Methods

getConfig(): Neo4jConfig;
getReadSession(database?: string): Session;
getWriteSession(database?: string): Session;
read(query: string, params?: object, database?: string): Result;
write(query: string, params?: object, database?: string): Result;

About

A NestJS module for integrating with Neo4j

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%