Browse Source

refactor(nocodb): remove unnecessary created_at and updated_at from models

pull/5269/head
Wing-Kam Wong 2 years ago
parent
commit
ff34b29499
  1. 9
      packages/nocodb/src/lib/models/Audit.ts
  2. 12
      packages/nocodb/src/lib/models/Hook.ts
  3. 10
      packages/nocodb/src/lib/models/HookLog.ts
  4. 9
      packages/nocodb/src/lib/models/ModelRoleVisibility.ts
  5. 10
      packages/nocodb/src/lib/models/Project.ts
  6. 10
      packages/nocodb/src/lib/models/SyncLogs.ts
  7. 7
      packages/nocodb/src/lib/models/SyncSource.ts
  8. 4
      packages/nocodb/src/lib/models/View.ts

9
packages/nocodb/src/lib/models/Audit.ts

@ -78,12 +78,7 @@ export default class Audit implements AuditType {
// Will only await for Audit insertion if `forceAwait` is true, which will be true in test environment by default
public static async insert(
audit: Partial<
Audit & {
created_at?;
updated_at?;
}
>,
audit: Partial<Audit>,
ncMeta = Noco.ncMeta,
{ forceAwait }: { forceAwait: boolean } = {
forceAwait: process.env['TEST'] === 'true',
@ -105,8 +100,6 @@ export default class Audit implements AuditType {
'status',
'description',
'details',
'created_at',
'updated_at',
]);
if (!insertObj.project_id && insertObj.fk_model_id) {
insertObj.project_id = (

12
packages/nocodb/src/lib/models/Hook.ts

@ -113,15 +113,7 @@ export default class Hook implements HookType {
return hooks?.map((h) => new Hook(h));
}
public static async insert(
hook: Partial<
Hook & {
created_at?;
updated_at?;
}
>,
ncMeta = Noco.ncMeta
) {
public static async insert(hook: Partial<Hook>, ncMeta = Noco.ncMeta) {
const insertObj = extractProps(hook, [
'fk_model_id',
'title',
@ -140,8 +132,6 @@ export default class Hook implements HookType {
'active',
'project_id',
'base_id',
'created_at',
'updated_at',
]);
if (insertObj.event) {

10
packages/nocodb/src/lib/models/HookLog.ts

@ -64,15 +64,7 @@ export default class HookLog implements HookLogType {
return hookLogs?.map((h) => new HookLog(h));
}
public static async insert(
hookLog: Partial<
HookLog & {
created_at?;
updated_at?;
}
>,
ncMeta = Noco.ncMeta
) {
public static async insert(hookLog: Partial<HookLog>, ncMeta = Noco.ncMeta) {
const insertObj: any = extractProps(hookLog, [
'base_id',
'project_id',

9
packages/nocodb/src/lib/models/ModelRoleVisibility.ts

@ -127,12 +127,7 @@ export default class ModelRoleVisibility implements ModelRoleVisibilityType {
}
static async insert(
body: Partial<
ModelRoleVisibilityType & {
created_at?;
updated_at?;
}
>,
body: Partial<ModelRoleVisibilityType>,
ncMeta = Noco.ncMeta
) {
const insertObj = extractProps(body, [
@ -141,8 +136,6 @@ export default class ModelRoleVisibility implements ModelRoleVisibilityType {
'fk_view_id',
'project_id',
'base_id',
'created_at',
'updated_at',
]);
if (!(insertObj.project_id && insertObj.base_id)) {

10
packages/nocodb/src/lib/models/Project.ts

@ -24,9 +24,6 @@ export default class Project implements ProjectType {
public is_meta = false;
public bases?: Base[];
created_at: any;
updated_at: any;
// shared base props
uuid?: string;
password?: string;
@ -37,10 +34,7 @@ export default class Project implements ProjectType {
}
public static async createProject(
project: ProjectType & {
created_at?;
updated_at?;
},
project: Partial<ProjectType>,
ncMeta = Noco.ncMeta
): Promise<Project> {
const insertObj = extractProps(project, [
@ -49,8 +43,6 @@ export default class Project implements ProjectType {
'prefix',
'description',
'is_meta',
'created_at',
'updated_at',
]);
const { id: projectId } = await ncMeta.metaInsert2(

10
packages/nocodb/src/lib/models/SyncLogs.ts

@ -26,15 +26,7 @@ export default class SyncLogs {
return syncLogs?.map((h) => new SyncLogs(h));
}
public static async insert(
syncLog: Partial<
SyncLogs & {
created_at?;
updated_at?;
}
>,
ncMeta = Noco.ncMeta
) {
public static async insert(syncLog: Partial<SyncLogs>, ncMeta = Noco.ncMeta) {
const insertObj = extractProps(syncLog, [
'project_id',
'fk_sync_source_id',

7
packages/nocodb/src/lib/models/SyncSource.ts

@ -65,12 +65,7 @@ export default class SyncSource {
}
public static async insert(
syncSource: Partial<
SyncSource & {
created_at?;
updated_at?;
}
>,
syncSource: Partial<SyncSource>,
ncMeta = Noco.ncMeta
) {
const insertObj = extractProps(syncSource, [

4
packages/nocodb/src/lib/models/View.ts

@ -246,8 +246,6 @@ export default class View implements ViewType {
Partial<FormView | GridView | GalleryView | KanbanView | MapView> & {
copy_from_id?: string;
fk_grp_col_id?: string;
created_at?;
updated_at?;
},
ncMeta = Noco.ncMeta
) {
@ -259,8 +257,6 @@ export default class View implements ViewType {
'fk_model_id',
'project_id',
'base_id',
'created_at',
'updated_at',
'meta',
]);

Loading…
Cancel
Save