Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adam-cowley/nest-neo4j
A NestJS module for integrating with Neo4j
https://github.com/adam-cowley/nest-neo4j
database hacktoberfest neo4j nestjs
Last synced: 4 days ago
JSON representation
A NestJS module for integrating with Neo4j
- Host: GitHub
- URL: https://github.com/adam-cowley/nest-neo4j
- Owner: adam-cowley
- License: apache-2.0
- Created: 2020-06-29T15:26:09.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-15T16:26:07.000Z (almost 2 years ago)
- Last Synced: 2024-12-05T20:24:43.130Z (17 days ago)
- Topics: database, hacktoberfest, neo4j, nestjs
- Language: TypeScript
- Homepage:
- Size: 118 KB
- Stars: 71
- Watchers: 8
- Forks: 22
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nest Neo4j
> Neo4j integration for Nest
## Description
This repository provides [Neo4j](https://www.neo4j.com) integration for [Nest](http://nestjs.com/).
## Installation
```
$ npm i --save nest-neo4j
```## Quick Start
Register the Neo4j Module in your application using the `forRoot` method, passing the neo4j connection information as an object:
```ts
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { Neo4jModule } from 'nest-neo4j'@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:
```ts
import { Neo4jService } from 'nest-neo4j'@Controller()
export class AppController {
constructor(private readonly appService: AppService,
private readonly neo4jService: Neo4jService
) {}@Get()
async getHello(): Promise {
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
```ts
getConfig(): Neo4jConnection;
getReadSession(database?: string): Session;
getWriteSession(database?: string): Session;
read(query: string, params?: object, database?: string): Result;
write(query: string, params?: object, database?: string): Result;
```# More Information
For more information about running Neo4j in your Node.js or TypeScript project, check out [Neo4j GraphAcademy](https://graphacademy.neo4j.com).