ModelQueryResult: also return model original data
This commit is contained in:
parent
e29b6369af
commit
7b739ff056
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wms-core",
|
"name": "wms-core",
|
||||||
"version": "0.21.11",
|
"version": "0.21.12",
|
||||||
"description": "Node web application framework and toolbelt.",
|
"description": "Node web application framework and toolbelt.",
|
||||||
"repository": "https://gitlab.com/ArisuOngaku/wms-core",
|
"repository": "https://gitlab.com/ArisuOngaku/wms-core",
|
||||||
"author": "Alice Gaudon <alice@gaudon.pro>",
|
"author": "Alice Gaudon <alice@gaudon.pro>",
|
||||||
|
@ -194,6 +194,7 @@ export default class ModelQuery<M extends Model> implements WhereFieldConsumer<M
|
|||||||
public async get(connection?: Connection): Promise<ModelQueryResult<M>> {
|
public async get(connection?: Connection): Promise<ModelQueryResult<M>> {
|
||||||
const queryResult = await this.execute(connection);
|
const queryResult = await this.execute(connection);
|
||||||
const models: ModelQueryResult<M> = [];
|
const models: ModelQueryResult<M> = [];
|
||||||
|
models.originalData = [];
|
||||||
|
|
||||||
if (this._pivot) models.pivot = [];
|
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);
|
const model = this.factory.create(modelData);
|
||||||
models.push(model);
|
models.push(model);
|
||||||
|
models.originalData.push(modelData);
|
||||||
|
|
||||||
if (this._pivot) {
|
if (this._pivot) {
|
||||||
const pivotData: any = {};
|
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> {
|
export interface ModelQueryResult<M extends Model> extends Array<M> {
|
||||||
|
originalData?: any[];
|
||||||
pagination?: Pagination<M>;
|
pagination?: Pagination<M>;
|
||||||
pivot?: { [p: string]: any }[];
|
pivot?: { [p: string]: any }[];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user