nestjs-notarealdb
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Nest.js Json Based DB.

release

You don't need to prepare DB. use json file.

  • simple wrapper of package mirkonasato/notarealdb for NestJS
  • Attention This is not for Production use.

  • only development use is prefer

Installation

npm install nestjs-notarealdb

Example module setup

import at app.module.ts

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ApplesModule } from './apples/apples.module';
import { NotARealDbModule } from 'nestjs-notarealdb';

@Module({
  imports: [
    ApplesModule,
    NotARealDbModule.forRoot({
      dataDirName: 'store' // anyting you want. default 'data'
    })],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

Then, import at feature modules like this

import { Module } from '@nestjs/common';
import { ApplesService } from './apples.service';
import { ApplesController } from './apples.controller';
import { Apple } from '../shared/models/apple.model';
import { NotARealDbModule } from 'nestjs-notarealdb';

@Module({
  imports:[
    NotARealDbModule.forFeature([Apple])
  ],
  controllers: [
    ApplesController,
  ],
  providers: [ApplesService]
})
export class ApplesModule {}

service: @InjectCollection is need.

export class ApplesService {
  constructor(@InjectCollection(Apple) private readonly collection: Collection<Apple>) {
  }

  create(createAppleDto: CreateAppleDto) {
    return this.collection.create(createAppleDto)
  }

  findAll() {
    this.collection.list()
  }

  findOne(id: string) {
    return this.collection.get(id)
  }

.....................

}

License

The code is under MIT license. See the LICENSE file for details.

Readme

Keywords

none

Package Sidebar

Install

npm i nestjs-notarealdb

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

458 kB

Total Files

115

Last publish

Collaborators

  • starcharles