update
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
import { ReferenceRange } from "entity";
|
||||
import { SelectQueryBuilder } from "typeorm";
|
||||
import CommonHelper from "../helpers/common";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
import { ILogObj, Logger } from "tslog";
|
||||
|
||||
export class ReferenceRangeModel {
|
||||
static async list(filter: Record<string, any> = {}): Promise<SelectQueryBuilder<any>> {
|
||||
@ -13,10 +11,17 @@ export class ReferenceRangeModel {
|
||||
if (filter && Object.keys(filter).length > 0) {
|
||||
Object.entries(filter).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null && value !== "") {
|
||||
query.andWhere(`ReferenceRange.${key} = :${key}`, { [key]: value });
|
||||
|
||||
// 🔥 Handle kalau ada yang kirim "ReferenceRange.id"
|
||||
const field = key.includes(".") ? key.split(".")[1] : key;
|
||||
|
||||
query.andWhere(`ReferenceRange.${field} = :${field}`, {
|
||||
[field]: value,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user