mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 07:10:53 +00:00
Refactor BaseModel and ModelPermission classes to improve column handling
This commit is contained in:
parent
83e207a7de
commit
6692fb00b8
@ -371,6 +371,10 @@ export default class BaseModel extends BaseEntity {
|
||||
}
|
||||
}
|
||||
|
||||
public isTableColumn(columnName: string): boolean {
|
||||
return Boolean(getTableColumn(this, columnName));
|
||||
}
|
||||
|
||||
public isEntityColumn(columnName: string): boolean {
|
||||
const tableColumnType: TableColumnMetadata = getTableColumn(
|
||||
this,
|
||||
|
@ -649,6 +649,10 @@ export default class ModelPermission {
|
||||
const relationSelect: RelationSelect<TBaseModel> = {};
|
||||
|
||||
for (const key in select) {
|
||||
if (!model.isTableColumn(key)) {
|
||||
delete (select as JSONObject)[key];
|
||||
}
|
||||
|
||||
if (model.isEntityColumn(key)) {
|
||||
if (typeof (select as JSONObject)[key] === Typeof.Object) {
|
||||
(relationSelect as any)[key] = true;
|
||||
|
Loading…
Reference in New Issue
Block a user