Init Nest-Neo4j
This commit is contained in:
21
Nest/src/app.service.ts
Normal file
21
Nest/src/app.service.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Node } from 'neo4j-driver';
|
||||
import { Neo4jService } from 'src/neo4j/neo4j.service';
|
||||
|
||||
export type User = Node;
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
constructor(private readonly neo4jService: Neo4jService) {}
|
||||
|
||||
async getHello(): Promise<string> {
|
||||
const result = await this.neo4jService.read(
|
||||
`MATCH (n) RETURN count(n) AS count`,
|
||||
{},
|
||||
);
|
||||
|
||||
const count = result.records[0].get('count');
|
||||
|
||||
return `${count} nodes in the database`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user