Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grapeoffjs/kindagoose
Typegoose integration with NestJS!
https://github.com/grapeoffjs/kindagoose
hacktoberfest mongodb mongoose nest nestjs typegoose typescript
Last synced: about 1 month ago
JSON representation
Typegoose integration with NestJS!
- Host: GitHub
- URL: https://github.com/grapeoffjs/kindagoose
- Owner: GrapeoffJS
- License: gpl-3.0
- Created: 2022-07-12T23:21:34.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-15T07:49:42.000Z (5 months ago)
- Last Synced: 2024-11-15T04:36:34.119Z (about 1 month ago)
- Topics: hacktoberfest, mongodb, mongoose, nest, nestjs, typegoose, typescript
- Language: TypeScript
- Homepage: https://grapeoffjs.github.io/kindagoose/#/
- Size: 428 KB
- Stars: 27
- Watchers: 1
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Kindagoose
Fresh NestJS wrapper for Typegoose that solves the main drawback
of [nestjs-typegoose](https://github.com/kpfromer/nestjs-typegoose)[![GPLv3 License](https://img.shields.io/badge/License-GPL%20v3-yellow.svg)](https://github.com/GrapeoffJS/kindagoose/blob/master/README.md)
[![Link to NPM](https://img.shields.io/badge/npm-kindagoose-red)](https://www.npmjs.com/package/kindagoose)## Authors
- [@Dmitriy Grape](https://github.com/GrapeoffJS)
- [@BackOnTrack](https://github.com/BackOnTrackgithub)## Support
For support, email me [email protected] 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/typegoose mongoose
```#### Yarn
```shell
$ yarn add kindagoose @typegoose/typegoose mongoose
```## Documentation
[Full documentation is available here!](https://grapeoffjs.github.io/kindagoose)
## Usage
#### Define a schema
```typescript
@modelOptions({ schemaOptions: { collection: 'Users' } })
export class User extends TimeStamps {
@prop({ unique: true })
login: string;@prop()
firstName: string;@prop()
lastName: string;@prop({ type: () => Date })
age: Date;@prop()
password: string;@prop({ type: () => [Task], localField: '_id', foreignField: 'owner_id' })
tasks: Ref[];
}
```#### Register your schema like this
```typescript
@Module({
imports: [
KindagooseModule.forFeature([
User,
]),
],
controllers: [],
providers: [UsersService],
})
export class UsersModule {}
```#### Use it wherever within the module
```typescript
import { InjectModel } from "kindagoose";
import { ReturnModelType } from "@typegoose/typegoose";@Injectable()
export class UsersService {
constructor(
@InjectModel(User)
private readonly userModel: ReturnModelType,
) {}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)