import { ColumnOptions, ValueTransformer } from 'typeorm'; /** * `decimal` 컬럼을 숫자로 읽고 쓰는 변환기. * * Postgres·MySQL 은 `decimal` 을 **문자열**로 돌려준다(정밀도를 지키려고). 그대로 두면 * GraphQL `Float` 필드와 합산 코드가 `'1200.00' + 300` 같은 글자 이어붙이기를 한다. * 그래서 읽을 때 숫자로 바꾼다. 비어 있음(`null`·`undefined`)은 그대로 둔다 — 0 으로 만들지 않는다. */ export declare const decimalTransformer: ValueTransformer; /** * 금액 컬럼 — `decimal(18, 2)`. * * ## 왜 `decimal` 인가 * * - 형식을 적지 않은 `number` 컬럼은 32비트 정수가 된다. 원 단위로는 정확하지만 한 칸에 * 약 21억까지이고 소수(센트)를 못 담는다. * - `float` 은 0.1 을 정확히 담지 못한다. 수천 줄을 더하면 은행 잔액과 어긋난다. * - `decimal` 은 SQL 표준이라 다섯 드라이버(postgres·mysql/mariadb·sqlite·mssql·oracle)가 모두 받는다. * 18자리 중 소수 2자리 — 원화 금액 전부와 외화 센트를 담는다. * * sqlite 는 자릿수를 강제하지 않는다(NUMERIC 친화형). 정수 원화는 정확하지만 소수 금액은 * 내부에서 실수로 담길 수 있다 — 소수 금액의 정확성은 서버 DB 를 전제로 한다. * * ## 쓰는 법 * * ```ts * @Column({ nullable: true, ...moneyColumn() }) * @Field(type => Float, { nullable: true }) * supplyAmount?: number * ``` * * `nullable`·`default` 같은 나머지 옵션은 호출하는 쪽이 정한다. GraphQL 필드는 `Float` 로 둔다. */ export declare function moneyColumn(options?: ColumnOptions): ColumnOptions; /** * A quantity — `decimal(18, 6)`: a count, a weight, a length, a dose. * * `float` and `double precision` do not hold 0.1 exactly, and `'double precision'` is a Postgres name that the other * drivers do not take. Six places carry grams in kilograms and millilitres in litres; twelve before the point carry * any stock a site keeps. Read back as a number, as `moneyColumn` is. The GraphQL field stays `Float`. */ export declare function quantityColumn(options?: ColumnOptions): ColumnOptions; /** A rate — `decimal(18, 6)`: won per unit of a currency, a unit price per unit of measure. */ export declare function rateColumn(options?: ColumnOptions): ColumnOptions; /** A percentage such as an interest rate — `decimal(9, 4)`. */ export declare function percentColumn(options?: ColumnOptions): ColumnOptions;