From a1edc241f14c2fba98b38eed9bfa4d7ee13f7c32 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Apr 2022 23:45:19 +0530 Subject: [PATCH] refactor: bulk api update Signed-off-by: Pranav C --- .../lib/dataMapper/lib/sql/BaseModelSqlv2.ts | 5 +- .../meta/api/dataApis/bulkDataAliasApis.ts | 10 +- scripts/sdk/swagger.json | 195 ------------------ 3 files changed, 7 insertions(+), 203 deletions(-) diff --git a/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts b/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts index fe5d8d34c6..3a2e9d43f3 100644 --- a/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts +++ b/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts @@ -2053,9 +2053,8 @@ function extractFilterFromXwhere( function extractCondition(nestedArrayConditions, aliasColObjMap) { return nestedArrayConditions?.map(str => { // eslint-disable-next-line prefer-const - let [logicOp, alias, op, value] = str - .match(/(?:~(and|or|not))?\((.*?),(\w+),(.*)\)/) - .slice(1); + let [logicOp, alias, op, value] = + str.match(/(?:~(and|or|not))?\((.*?),(\w+),(.*)\)/)?.slice(1) || []; if (op === 'is') op = 'is' + value; else if (op === 'in') value = value.split(','); diff --git a/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts b/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts index f8d907fc9c..6bda7361d7 100644 --- a/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/dataApis/bulkDataAliasApis.ts @@ -91,23 +91,23 @@ async function getViewAndModelFromRequest(req) { const router = Router({ mergeParams: true }); router.post( - '/api/v1/db/bulk-data/:orgs/:projectName/:tableAlias', + '/api/v1/db/data/bulk/:orgs/:projectName/:tableAlias', ncMetaAclMw(bulkDataInsert, 'bulkDataInsert') ); router.patch( - '/api/v1/db/bulk-data/:orgs/:projectName/:tableAlias', + '/api/v1/db/data/bulk/:orgs/:projectName/:tableAlias', ncMetaAclMw(bulkDataUpdate, 'bulkDataUpdate') ); router.patch( - '/api/v1/db/bulk-data/:orgs/:projectName/:tableAlias/all', + '/api/v1/db/data/bulk/:orgs/:projectName/:tableAlias/all', ncMetaAclMw(bulkDataUpdateAll, 'bulkDataUpdateAll') ); router.delete( - '/api/v1/db/bulk-data/:orgs/:projectName/:tableAlias', + '/api/v1/db/data/bulk/:orgs/:projectName/:tableAlias', ncMetaAclMw(bulkDataDelete, 'bulkDataDelete') ); router.delete( - '/api/v1/db/bulk-data/:orgs/:projectName/:tableAlias/all', + '/api/v1/db/data/bulk/:orgs/:projectName/:tableAlias/all', ncMetaAclMw(bulkDataDeleteAll, 'bulkDataDeleteAll') ); diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 321dac3b13..c2c121aa66 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -4494,201 +4494,6 @@ ] }, - "/api/v1/db/bulk-data/{orgs}/{projectName}/{tableName}/": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "orgs", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "projectName", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "tableName", - "in": "path", - "required": true - } - ], - "delete": { - "summary": "", - "operationId": "db-table-row-bulk-delete", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB Table Row" - ], - "description": "", - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": {} - } - } - } - } - }, - "post": { - "summary": "", - "operationId": "db-table-row-bulk-insert", - "responses": { - "200": { - "description": "OK" - } - }, - "tags": [ - "DB Table Row" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": {} - } - } - } - } - }, - "patch": { - "summary": "", - "operationId": "db-table-row-bulk-update", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": {}, - "examples": {} - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object" - } - } - } - } - }, - "tags": [ - "DB Table Row" - ] - } - }, - "/api/v1/db/bulk-data/{orgs}/{projectName}/{tableName}/all": { - "parameters": [ - { - "schema": { - "type": "string" - }, - "name": "orgs", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "projectName", - "in": "path", - "required": true - }, - { - "schema": { - "type": "string" - }, - "name": "tableName", - "in": "path", - "required": true - } - ], - "patch": { - "summary": "", - "operationId": "db-table-row-bulk-update-all", - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "description": "", - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "parameters": [ - { - "schema": { - "type": "string" - }, - "in": "query", - "name": "where" - } - ], - "tags": [ - "DB Table Row" - ] - }, - "delete": { - "summary": "", - "operationId": "db-table-row-bulk-delete-all", - "responses": { - "200": { - "description": "OK", - "headers": {}, - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "parameters": [ - { - "schema": { - "type": "string" - }, - "in": "query", - "name": "where" - } - ], - "tags": [ - "DB Table Row" - ] - } - }, - "/api/v1/db/storage/upload": { "post": { "summary": "Attachment",