import { AttributeAlias } from "./alias"; import { Attribute } from "./db"; import { primaryData } from "./types"; export class singleResponse { [key: string]: primaryData | any; constructor(r: object) { Object.assign(this, r); } getVal(a: Attribute | AttributeAlias) { return this[a.toString()]; } } export class readResponse extends Array{ constructor(rows: ({ [key: string]: primaryData })[]) { super(); this.push(...rows.map(r => new singleResponse(r))); } } export class writeResponse { affectedRows: number; constructor(affectedRows: number) { this.affectedRows = affectedRows; } } export class insertResponse extends writeResponse { insertId: number; constructor(affectedRows: number, insertId: number) { super(affectedRows); this.insertId = insertId; } }