Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: use internal api for extension table data crud operation

Ramesh Manef721b68fbefd
diff --git a/packages/nc-gui/composables/useExtensionHelper.ts b/packages/nc-gui/composables/useExtensionHelper.ts
index 2dc9982da7..bd3540ea35 100644
--- a/packages/nc-gui/composables/useExtensionHelper.ts
+++ b/packages/nc-gui/composables/useExtensionHelper.ts
@@ -118,7 +118,11 @@ const [useProvideExtensionHelper, useExtensionHelper] = useInjectionState(
for (const chunk of chunks) {
inserted += chunk.length
- await $api.dbDataTableRow.create(tableId, chunk, params.autoInsertOption ? ({ typecast: 'true' } as any) : undefined)
+ await $api.internal.postOperation(activeWorkspaceId.value!, baseId.value!, {
+ operation: 'dataInsert',
+ tableId,
+ ...(params.autoInsertOption ? { typecast: 'true' } : {}),
+ }, chunk)
}
return {
@@ -140,6 +144,11 @@ const [useProvideExtensionHelper, useExtensionHelper] = useInjectionState(
for (const chunk of chunks) {
updated += chunk.length
+ await $api.internal.postOperation(activeWorkspaceId.value!, baseId.value!, {
+ operation: 'dataUpdate',
+ tableId
+ }, chunk)
+
await $api.dbDataTableRow.update(tableId, chunk)
}
@@ -168,22 +177,22 @@ const [useProvideExtensionHelper, useExtensionHelper] = useInjectionState(
if (insert.length) {
insertCounter += insert.length
while (insert.length) {
- await $api.dbDataTableRow.create(
+ await $api.internal.postOperation(activeWorkspaceId.value!, baseId.value!, {
+ operation: 'dataInsert',
tableId,
- insert.splice(0, chunkSize),
- params.autoInsertOption ? ({ typecast: 'true' } as any) : undefined,
- )
+ ...(params.autoInsertOption ? { typecast: 'true' } : {}),
+ }, insert.splice(0, chunkSize))
}
}
if (update.length) {
updateCounter += update.length
while (update.length) {
- await $api.dbDataTableRow.update(
+ await $api.internal.postOperation(activeWorkspaceId.value!, baseId.value!, {
+ operation: 'dataUpdate',
tableId,
- update.splice(0, chunkSize),
- params.autoInsertOption ? ({ typecast: 'true' } as any) : undefined,
- )
+ ...(params.autoInsertOption ? { typecast: 'true' } : {}),
+ }, update.splice(0, chunkSize))
}
}
diff --git a/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts b/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts
index 0d4929fb32..806ac2d7ff 100644
--- a/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts
+++ b/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts
@@ -34,8 +34,7 @@ import { ExtensionsService } from '~/services/extensions.service';
@Injectable()
export class UiPostOperations
- implements InternalApiModule<InternalPOSTResponseType>
-{
+ implements InternalApiModule<InternalPOSTResponseType> {
constructor(
protected dataTableService: DataTableService,
protected tablesService: TablesService,
@@ -59,7 +58,7 @@ export class UiPostOperations
protected syncService: SyncService,
protected readonly nocoJobsService: NocoJobsService,
protected extensionsService: ExtensionsService,
- ) {}
+ ) { }
operations = [
'tableUpdate' as const,
'tableDelete' as const,
@@ -117,12 +116,14 @@ export class UiPostOperations
'rowColorConditionsFilterCreate' as const,
'bulkAggregate' as const,
'bulkDataList' as const,
+ 'dataInsert' as const,
+ 'dataUpdate' as const,
+ 'dataDelete' as const,
+ 'bulkDataDeleteAll' as const,
'commentRow' as const,
'commentUpdate' as const,
'commentDelete' as const,
'commentResolve' as const,
- 'dataDelete' as const,
- 'bulkDataDeleteAll' as const,
'syncSourceCreate' as const,
'syncSourceUpdate' as const,
'syncSourceDelete' as const,
@@ -494,6 +495,15 @@ export class UiPostOperations
user: req.user,
},
);
+ case 'bulkAggregate':
+ context.cache = true;
+ return await this.dataTableService.bulkAggregate(context, {
+ query: req.query,
+ modelId: req.query.tableId as string,
+ viewId: req.query.viewId as string,
+ baseId: req.query.baseId as string,
+ body: payload,
+ });
case 'bulkDataList':
return await this.dataTableService.bulkDataList(context, {
query: req.query,
@@ -528,24 +538,22 @@ export class UiPostOperations
name: job.name,
};
}
- case 'commentRow':
- return await this.commentsService.commentRow(context, {
+ case 'dataInsert':
+ return await this.dataTableService.dataInsert(context, {
+ modelId: req.query.tableId as string,
body: payload,
+ viewId: req.query.viewId as string,
+ cookie: req,
+ undo: req.query.undo === 'true',
user: req.user,
- req,
});
- case 'commentUpdate':
- return await this.commentsService.commentUpdate(context, {
- commentId: payload.commentId,
- user: req.user,
+ case 'dataUpdate':
+ return await this.dataTableService.dataUpdate(context, {
+ modelId: req.query.tableId as string,
body: payload,
- req,
- });
- case 'commentDelete':
- return await this.commentsService.commentDelete(context, {
- commentId: payload.commentId,
+ viewId: req.query.viewId as string,
+ cookie: req,
user: req.user,
- req,
});
case 'dataDelete':
return await this.dataTableService.dataDelete(context, {
@@ -563,14 +571,25 @@ export class UiPostOperations
viewName: req.query.viewId,
req,
});
- case 'bulkAggregate':
- context.cache = true;
- return await this.dataTableService.bulkAggregate(context, {
- query: req.query,
- modelId: req.query.tableId as string,
- viewId: req.query.viewId as string,
- baseId: req.query.baseId as string,
+
+ case 'commentRow':
+ return await this.commentsService.commentRow(context, {
+ body: payload,
+ user: req.user,
+ req,
+ });
+ case 'commentUpdate':
+ return await this.commentsService.commentUpdate(context, {
+ commentId: payload.commentId,
+ user: req.user,
body: payload,
+ req,
+ });
+ case 'commentDelete':
+ return await this.commentsService.commentDelete(context, {
+ commentId: payload.commentId,
+ user: req.user,
+ req,
});
case 'syncSourceCreate':
return await this.syncService.syncCreate(context, {
diff --git a/packages/nocodb/src/controllers/internal/operationScopes.ts b/packages/nocodb/src/controllers/internal/operationScopes.ts
index 487e42db5b..cbb421c354 100644
--- a/packages/nocodb/src/controllers/internal/operationScopes.ts
+++ b/packages/nocodb/src/controllers/internal/operationScopes.ts
@@ -107,6 +107,8 @@ export const OPERATION_SCOPES = {
commentResolve: 'base',
dataList: 'base',
linkDataList: 'base',
+ dataInsert: 'base',
+ dataUpdate: 'base',
dataDelete: 'base',
dataDeleteAll: 'base',
bulkDataDeleteAll: 'base',