A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.
$ npm i --save @hungtcs-box/nest-nedb nedb
$ npm i --save-dev @types/nedb
- First in your model file, extends the base
Model
import { Model } from '@hungtcs-box/nest-nedb';
export class UserModel extends Model {
username?: string;
}
- Import
NedbModule.forFeature
in yourUsersModule
import { UserModel } from './models/user.model';
import { NedbModule } from '@hungtcs-box/nest-nedb';
@Module({
imports: [
PasswdModule,
NedbModule.forFeature([
{
model: UserModel,
indexes: {
username: {
unique: true,
},
},
},
]),
],
exports: [
UsersService,
],
providers: [
UsersService,
],
controllers: [
UsersController,
],
})
export class UsersModule {
}
- Import
NedbModule.forRoot
in yourAppModule
import { NedbModule } from '@hungtcs-box/nest-nedb';
@Module({
imports: [
NedbModule.forRoot(`path/to/your/database/file`),
],
controllers: [
AppController,
],
})
export class AppModule {
}
- Now you can inject the nedb DataStore in your
UserService
import { InjectDatastore } from '@hungtcs-box/nest-nedb';
import DataStore from 'nedb';
@Injectable()
export class UsersService {
constructor(
@InjectDatastore(UserModel) private readonly dataStore: DataStore<UserModel>) {
}
}
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest and Nedb is MIT licensed.