@cybercoder/nest-json-db
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Nest JSON DB

A module that implements node-json-db as a NestJS dynamic module.


Example usage:

Import the module:

import { NestJSONDBModule } from '@cybercoder/nest-json-db';
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  imports: [
    NestJSONDBModule.forRootAsync({
      useFactory: () => ({
        filename: 'myJSONdbFile',
        // humanReadable: true,
        // separator: '/',
        // saveOnPush: true,
        // syncOnSave: true,
      }),
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

Service usage example:

mport { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { JsonDBService } from '@cybercoder/nest-json-db';
@Controller()
export class AppController {
  constructor(
    private readonly appService: AppService,
    private readonly jsonDBService: JsonDBService,
  ) {}

  @Get()
  getHello(): string {
    this.jsonDBService.push(
      '/',
      {
        new: 'cool',
        json: {
          important: 5,
        },
      },
      false,
    );
    return this.appService.getHello();
  }
}

You can find node-json-db examples and documentation here.

Readme

Keywords

none

Package Sidebar

Install

npm i @cybercoder/nest-json-db

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

99.6 kB

Total Files

29

Last publish

Collaborators

  • cybercoder