kindagoose
Version:
Integrate Typegoose with NestJS!
110 lines (77 loc) • 2.32 kB
Markdown
# Kindagoose
Fresh NestJS wrapper for Typegoose that solves the main drawback
of [nestjs-typegoose](https://github.com/kpfromer/nestjs-typegoose)
[](https://github.com/GrapeoffJS/kindagoose/blob/master/README.md)
[](https://www.npmjs.com/package/kindagoose)
## Authors
- [ Grape](https://github.com/GrapeoffJS)
- [](https://github.com/BackOnTrackgithub)
## Support
For support, email me grapeoff.official@gmail.com or write an issue straight in kindagoose repository!
## Installation
To install `kindagoose`, you need to execute one of these simple commands:
#### NPM
```shell
$ npm i kindagoose /typegoose mongoose
```
#### Yarn
```shell
$ yarn add kindagoose /typegoose mongoose
```
## Documentation
[Full documentation is available here!](https://grapeoffjs.github.io/kindagoose)
## Usage
#### Define a schema
```typescript
export class User extends TimeStamps {
login: string;
firstName: string;
lastName: string;
age: Date;
password: string;
tasks: Ref<Task>[];
}
```
#### Register your schema like this
```typescript
export class UsersModule {}
```
#### Use it wherever within the module
```typescript
import { InjectModel } from "kindagoose";
import { ReturnModelType } from "@typegoose/typegoose";
export class UsersService {
constructor(
private readonly userModel: ReturnModelType<typeof User>,
) {}
async create(createUserDto: CreateUserDto) {
return this.userModel.create(createUserDto);
}
async get({ limit, offset }: PaginationDto) {
return this.userModel.find().skip(offset).limit(limit).exec();
}
async getById(id: string) {
return this.userModel.findById(id).exec();
}
}
```
## License
[GPL 3.0](https://github.com/GrapeoffJS/kindagoose/blob/master/LICENSE)