-
Notifications
You must be signed in to change notification settings - Fork 38
/
FloatField.ts
28 lines (22 loc) · 961 Bytes
/
FloatField.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Float } from 'type-graphql';
import { DecoratorCommonOptions } from '../metadata';
import { composeMethodDecorators } from '../utils';
import { FloatColumnType, FloatWhereOperator } from '../torm';
import { getCombinedDecorator } from './getCombinedDecorator';
interface FloatFieldOptions extends DecoratorCommonOptions {
dataType?: FloatColumnType; // int16, jsonb, etc...
default?: number;
filter?: boolean | FloatWhereOperator[];
}
export function FloatField(options: FloatFieldOptions = {}): any {
const nullableOption = options.nullable === true ? { nullable: true } : {};
const defaultOption = options.default ? { default: options.default } : {};
const factories = getCombinedDecorator({
fieldType: 'float',
warthogColumnMeta: options,
gqlFieldType: Float,
dbType: options.dataType ?? 'float8',
dbColumnOptions: { ...nullableOption, ...defaultOption }
});
return composeMethodDecorators(...factories);
}