UNPKG

pure-orm

Version:

A SQL Toolkit based on pure business objects passed to and from stateful data access objects

36 lines (29 loc) 717 B
import { Customer } from './customer'; import { IModel, ICollection, IColumns } from '../../../src/index'; export const tableName: string = 'order'; export const columns: IColumns = [ 'id', { column: 'customer_id', references: Customer } ]; export class Order implements IModel { id: number; customerId: number; customer?: Customer; constructor(props: any) { this.id = props.id; this.customerId = props.customerId; this.customer = props.customer; } } export class Orders implements ICollection<Order> { models: Array<Order>; constructor({ models }: any) { this.models = models; } } export const orderEntity = { tableName, columns, Model: Order, Collection: Orders };