This commit is contained in:
2024-10-14 16:06:21 +07:00
parent 12386d0255
commit 6c04f52ddd
2 changed files with 42 additions and 2 deletions

View File

@@ -14,7 +14,7 @@ import * as Prisma from '@prisma/client';
import { SchemaBuilderToken } from '@smatch-corp/nestjs-pothos';
//
const filterOps = ['equals', 'in', 'notIn', 'not', 'is', 'isNot'] as const;
const filterOps = ['equals', 'in', 'notIn', 'not', 'is'] as const;
const sortableFilterProps = ['lt', 'lte', 'gt', 'gte'] as const;
const stringFilterOps = [
...filterOps,
@@ -31,7 +31,7 @@ const scalarListOps = [
'isEmpty',
'equals',
] as const;
const JsonFilterOps = ['equals', 'in', 'notIn', 'not', 'is', 'isNot'] as const;
const JsonFilterOps = ['equals', 'in', 'notIn', 'not', 'is'] as const;
const EnumFilterOps = ['equals', 'not'] as const;
@Injectable()
@@ -564,6 +564,13 @@ export class PrismaCrudGenerator<Types extends SchemaTypes> {
if (sortableTypes.includes(type as never)) {
ops.push(...sortableFilterProps);
}
if (type === 'Json') {
ops.push(...JsonFilterOps);
}
// type enum
if (type === 'Enum') {
ops.push(...EnumFilterOps);
}
return this.builder.prismaFilter(type, {
ops,