ModelQueryResult: also return model original data

This commit is contained in:
Alice Gaudon 2020-09-04 22:44:30 +02:00
parent e29b6369af
commit 7b739ff056
2 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{
"name": "wms-core",
"version": "0.21.11",
"version": "0.21.12",
"description": "Node web application framework and toolbelt.",
"repository": "https://gitlab.com/ArisuOngaku/wms-core",
"author": "Alice Gaudon <alice@gaudon.pro>",

View File

@ -194,6 +194,7 @@ export default class ModelQuery<M extends Model> implements WhereFieldConsumer<M
public async get(connection?: Connection): Promise<ModelQueryResult<M>> {
const queryResult = await this.execute(connection);
const models: ModelQueryResult<M> = [];
models.originalData = [];
if (this._pivot) models.pivot = [];
@ -211,6 +212,7 @@ export default class ModelQuery<M extends Model> implements WhereFieldConsumer<M
const model = this.factory.create(modelData);
models.push(model);
models.originalData.push(modelData);
if (this._pivot) {
const pivotData: any = {};
@ -267,6 +269,7 @@ export default class ModelQuery<M extends Model> implements WhereFieldConsumer<M
}
export interface ModelQueryResult<M extends Model> extends Array<M> {
originalData?: any[];
pagination?: Pagination<M>;
pivot?: { [p: string]: any }[];
}