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 // Will only await for Audit insertion if `forceAwait` is true, which will be true in test environment by default
public static async insert( public static async insert(
audit: Partial< audit: Partial<Audit>,
Audit & {
created_at?;
updated_at?;
}
>,
ncMeta = Noco.ncMeta, ncMeta = Noco.ncMeta,
{ forceAwait }: { forceAwait: boolean } = { { forceAwait }: { forceAwait: boolean } = {
forceAwait: process.env['TEST'] === 'true', forceAwait: process.env['TEST'] === 'true',
@ -105,8 +100,6 @@ export default class Audit implements AuditType {
'status', 'status',
'description', 'description',
'details', 'details',
'created_at',
'updated_at',
]); ]);
if (!insertObj.project_id && insertObj.fk_model_id) { if (!insertObj.project_id && insertObj.fk_model_id) {
insertObj.project_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)); return hooks?.map((h) => new Hook(h));
} }
public static async insert( public static async insert(hook: Partial<Hook>, ncMeta = Noco.ncMeta) {
hook: Partial<
Hook & {
created_at?;
updated_at?;
}
>,
ncMeta = Noco.ncMeta
) {
const insertObj = extractProps(hook, [ const insertObj = extractProps(hook, [
'fk_model_id', 'fk_model_id',
'title', 'title',
@ -140,8 +132,6 @@ export default class Hook implements HookType {
'active', 'active',
'project_id', 'project_id',
'base_id', 'base_id',
'created_at',
'updated_at',
]); ]);
if (insertObj.event) { 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)); return hookLogs?.map((h) => new HookLog(h));
} }
public static async insert( public static async insert(hookLog: Partial<HookLog>, ncMeta = Noco.ncMeta) {
hookLog: Partial<
HookLog & {
created_at?;
updated_at?;
}
>,
ncMeta = Noco.ncMeta
) {
const insertObj: any = extractProps(hookLog, [ const insertObj: any = extractProps(hookLog, [
'base_id', 'base_id',
'project_id', 'project_id',

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

@ -127,12 +127,7 @@ export default class ModelRoleVisibility implements ModelRoleVisibilityType {
} }
static async insert( static async insert(
body: Partial< body: Partial<ModelRoleVisibilityType>,
ModelRoleVisibilityType & {
created_at?;
updated_at?;
}
>,
ncMeta = Noco.ncMeta ncMeta = Noco.ncMeta
) { ) {
const insertObj = extractProps(body, [ const insertObj = extractProps(body, [
@ -141,8 +136,6 @@ export default class ModelRoleVisibility implements ModelRoleVisibilityType {
'fk_view_id', 'fk_view_id',
'project_id', 'project_id',
'base_id', 'base_id',
'created_at',
'updated_at',
]); ]);
if (!(insertObj.project_id && insertObj.base_id)) { 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 is_meta = false;
public bases?: Base[]; public bases?: Base[];
created_at: any;
updated_at: any;
// shared base props // shared base props
uuid?: string; uuid?: string;
password?: string; password?: string;
@ -37,10 +34,7 @@ export default class Project implements ProjectType {
} }
public static async createProject( public static async createProject(
project: ProjectType & { project: Partial<ProjectType>,
created_at?;
updated_at?;
},
ncMeta = Noco.ncMeta ncMeta = Noco.ncMeta
): Promise<Project> { ): Promise<Project> {
const insertObj = extractProps(project, [ const insertObj = extractProps(project, [
@ -49,8 +43,6 @@ export default class Project implements ProjectType {
'prefix', 'prefix',
'description', 'description',
'is_meta', 'is_meta',
'created_at',
'updated_at',
]); ]);
const { id: projectId } = await ncMeta.metaInsert2( 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)); return syncLogs?.map((h) => new SyncLogs(h));
} }
public static async insert( public static async insert(syncLog: Partial<SyncLogs>, ncMeta = Noco.ncMeta) {
syncLog: Partial<
SyncLogs & {
created_at?;
updated_at?;
}
>,
ncMeta = Noco.ncMeta
) {
const insertObj = extractProps(syncLog, [ const insertObj = extractProps(syncLog, [
'project_id', 'project_id',
'fk_sync_source_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( public static async insert(
syncSource: Partial< syncSource: Partial<SyncSource>,
SyncSource & {
created_at?;
updated_at?;
}
>,
ncMeta = Noco.ncMeta ncMeta = Noco.ncMeta
) { ) {
const insertObj = extractProps(syncSource, [ 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> & { Partial<FormView | GridView | GalleryView | KanbanView | MapView> & {
copy_from_id?: string; copy_from_id?: string;
fk_grp_col_id?: string; fk_grp_col_id?: string;
created_at?;
updated_at?;
}, },
ncMeta = Noco.ncMeta ncMeta = Noco.ncMeta
) { ) {
@ -259,8 +257,6 @@ export default class View implements ViewType {
'fk_model_id', 'fk_model_id',
'project_id', 'project_id',
'base_id', 'base_id',
'created_at',
'updated_at',
'meta', 'meta',
]); ]);

Loading…
Cancel
Save