UNPKG

@sqb/connect

Version:

Multi-dialect database connection framework written with TypeScript

18 lines (17 loc) 756 B
import { EntityMetadata } from '../model/entity-metadata.js'; export function Parse(fn) { return (target, propertyKey) => { if (typeof propertyKey !== 'string') throw new Error('You can define a Column for only string properties'); const entity = EntityMetadata.define(target.constructor); EntityMetadata.defineColumnField(entity, propertyKey).parse = fn; }; } export function Serialize(fn) { return (target, propertyKey) => { if (typeof propertyKey !== 'string') throw new Error('You can define a Column for only string properties'); const entity = EntityMetadata.define(target.constructor); EntityMetadata.defineColumnField(entity, propertyKey).serialize = fn; }; }