Package Exports
- @ra-libs/nestjs
- @ra-libs/nestjs/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ra-libs/nestjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
React Admin Nestjs lib
This Package uses semantic-release to publish new versions. Check Angular Commit Message Conventions for new commits
Installation
Run npm install
npm install @ra-libs/nestjsInterceptors
PrismaRAInterceptor
Global usage
// main.ts
import { PrismaRAInterceptor } from '@ra-libs/nestjs'
async function bootstrap() {
const app = await NestFactory.create(AppModule, { cors: true });
// ...
app.useGlobalInterceptors(new PrismaRAInterceptor());
// ...
}
bootstrap();
Per controller usage
import { PrismaRAInterceptor } from '@ra-libs/nestjs'rom '@tech/olist-commons';
@UseInterceptors(PrismaRAInterceptor)
export class CatsController {}Check nestjs interceptor binding documentation
Utils
transformInputsToPrisma
Transform relation input data to handle it in prisma syntax using connect, disconnect methods
private relations: string[] = ["clients"]
async update(id: string, newSale: UpdateSaleDto) {
const sale = await this.findOne(id)
const updateData = transformInputsToPrisma(sale, newSale, this.relations) as any
return this.prisma.sale.update({
where: { id },
data: updateData,
});
}includeReferencesIDs
Include references IDs
import { includeReferencesIDs, transformOutputArraysToIds } from '@ra-libs/nestjs'
findOne(id: string): Promise<Client> {
return this.prisma.client
.findUnique({
where: { id },
include: includeReferencesIDs(["addresses", "passports", "sales", "documents"])
})
.then(transformOutputArraysToIds);transformOutputArraysToIds
Transform prisma outputs relations to IDs of string
import { includeReferencesIDs, transformOutputArraysToIds } from '@ra-libs/nestjs'
findOne(id: string): Promise<Seller> {
return this.prisma.seller.findUnique({
where: { id },
include: includeReferencesIDs(["sales"])
}).then(transformOutputArraysToIds)
}Change Log
See Changelog for more information.
Contributing
Contributions welcome! See Contributing.
Author
License
Licensed under the MIT License - see the LICENSE file for details.