New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

neode-nestjs

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neode-nestjs

This package provide a neode module for nestjs

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by800%
Maintainers
1
Weekly downloads
 
Created
Source

Neode NestJS

A module to connect Neode, Neo4j and NestJS.

Variables

.env

Ensure you are reading your .env before start your application You must add env-cmd before your script

{
     "start:dev": "env-cmd nest start --watch"
}
NEO4J_DATABASE=neo4j
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=your-password
NEO4J_HOST=localhost
NEO4J_PORT=7687
NEO4J_PROTOCOL=neo4j
NEO4J_ENCRYPTION=ENCRYPTION_OFF

Main module
import { NeodeModule } from 'neode-nestjs';

app.module.ts

@Module({
     imports: [NeodeModule.forRoot(), UserModule],
     controllers: [AppController],
     providers: [],
})
export class AppModule {}

Entities or Schemas

Your schema to inject on module

Important when you import Neode use like example bellow. Or you will have a problem with types

import * as Neode from 'neode';

Schema

import { SchemaObject } from 'neode';

const UserSchema: SchemaObject = {
     id: {
          type: 'uuid',
          primary: true,
          required: true,
     },
     name: {
          type: 'string',
          required: true,
     },
     email: {
          type: 'string',
          unique: true,
          required: true,
     },
     password: {
          type: 'string',
          required: true,
     },
     avatar: {
          type: 'string',
     },
     isFirstAuth: {
          type: 'boolean',
     },
};

export default UserSchema;

Specific module
@Module({
     imports: [NeodeModule.forFeature({ User: UserSchema })],
     controllers: [UserController],
     providers: [UserService],
})
export class UserModule {}

Service class

You can get connection by injected Connection. It returns a Neode instance

The word 'User' is the same you have used to inject on { User: UserSchema } if you use same different word as not User you must to use it.

@Injectable()
export class UserService {
     constructor(@Inject('Connection') private readonly neode: Neode) {}

     async createUser(dto: CreateUserDto): Promise<void> {
          await this.neode.merge('User', dto);
     }

     async getUsers(): Promise<UserInterface[]> {
          const users = await this.neode.all('User');
          return (await users.toJson()) as UserInterface[];
     }
}

Keywords

FAQs

Package last updated on 20 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc