Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 278x 62365x 62365x 278x 278x | import { AbstractDataType } from './abstract-data-type.ts';
/**
* `JSON` / `JSONB`; values are serialized to JSON text.
*
* @internal
*/
export class JsonType extends AbstractDataType {
/** Enables nested JSON where conditions. */
readonly isJson = true;
/** Converts a value into JSON text (`null` / `undefined` are kept). */
readonly serialize = (value: unknown): unknown =>
value === null || value === undefined ? value : JSON.stringify(value);
/**
* @param key - `'JSON'` or `'JSONB'` (also the SQL type).
*/
constructor(key: 'JSON' | 'JSONB') {
super(key, key);
Object.freeze(this);
}
}
|