add new: measurement_unit
This commit is contained in:
23
src/model/measurement_unit.ts
Normal file
23
src/model/measurement_unit.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { MeasurementUnit } from "entity";
|
||||
import { SelectQueryBuilder } from "typeorm";
|
||||
import CommonHelper from "../helpers/common";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
|
||||
export class MeasurementUnitModel {
|
||||
static async list(filter = {}): Promise<SelectQueryBuilder<any>> {
|
||||
const repo = OrmHelper.DB.getRepository(MeasurementUnit);
|
||||
let whereAttr: string[] = [];
|
||||
let whereVal: any = {};
|
||||
if (filter && Object.keys(filter).length > 0) {
|
||||
whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filter).whereAttr];
|
||||
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter).whereVal };
|
||||
}
|
||||
|
||||
var query = repo.createQueryBuilder("MeasurementUnit");
|
||||
if (whereAttr.length != 0) {
|
||||
query = query.where(whereAttr.join(" and "), whereVal);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user