2023-02-27 16:33:27 +01:00
|
|
|
import { AttributeAlias } from "./alias.js";
|
|
|
|
import { Attribute } from "./db.js";
|
|
|
|
import { primaryData } from "./types.js";
|
2023-02-22 11:13:43 +01:00
|
|
|
|
2023-02-25 14:52:46 +01:00
|
|
|
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<singleResponse>{
|
|
|
|
constructor(rows: ({ [key: string]: primaryData })[]) {
|
2023-02-22 11:13:43 +01:00
|
|
|
super();
|
2023-02-25 14:52:46 +01:00
|
|
|
this.push(...rows.map(r => new singleResponse(r)));
|
2023-02-22 11:13:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-25 14:52:46 +01:00
|
|
|
export class writeResponse {
|
2023-02-22 11:13:43 +01:00
|
|
|
affectedRows: number;
|
2023-02-25 14:52:46 +01:00
|
|
|
constructor(affectedRows: number) {
|
2023-02-22 11:13:43 +01:00
|
|
|
this.affectedRows = affectedRows;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-25 14:52:46 +01:00
|
|
|
export class insertResponse extends writeResponse {
|
2023-02-22 11:13:43 +01:00
|
|
|
insertId: number;
|
2023-02-25 14:52:46 +01:00
|
|
|
constructor(affectedRows: number, insertId: number) {
|
2023-02-22 11:13:43 +01:00
|
|
|
super(affectedRows);
|
|
|
|
this.insertId = insertId;
|
|
|
|
}
|
|
|
|
}
|