Browse Source

feat: bulkUpdateAll using viewId

Signed-off-by: mertmit <mertmit99@gmail.com>
test/pw-duplicate-check
mertmit 2 years ago
parent
commit
1b21cad9b5
  1. 2
      packages/nocodb-sdk/src/lib/Api.ts
  2. 36
      packages/nocodb/src/db/BaseModelSqlv2.ts
  3. 7
      packages/nocodb/src/schema/swagger.json

2
packages/nocodb-sdk/src/lib/Api.ts

@ -7249,6 +7249,7 @@ export class Api<
data: object, data: object,
query?: { query?: {
where?: string; where?: string;
viewId?: string;
}, },
params: RequestParams = {} params: RequestParams = {}
) => ) =>
@ -7289,6 +7290,7 @@ export class Api<
data: object, data: object,
query?: { query?: {
where?: string; where?: string;
viewId?: string;
}, },
params: RequestParams = {} params: RequestParams = {}
) => ) =>

36
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -2378,7 +2378,7 @@ class BaseModelSqlv2 {
} }
async bulkUpdateAll( async bulkUpdateAll(
args: { where?: string; filterArr?: Filter[] } = {}, args: { where?: string; filterArr?: Filter[]; viewId?: string } = {},
data, data,
{ cookie }: { cookie?: any } = {}, { cookie }: { cookie?: any } = {},
) { ) {
@ -2400,22 +2400,30 @@ class BaseModelSqlv2 {
const aliasColObjMap = await this.model.getAliasColObjMap(); const aliasColObjMap = await this.model.getAliasColObjMap();
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); const filterObj = extractFilterFromXwhere(where, aliasColObjMap);
await conditionV2( const conditionObj = [
[ new Filter({
new Filter({ children: args.filterArr || [],
children: args.filterArr || [], is_group: true,
is_group: true, logical_op: 'and',
logical_op: 'and', }),
}), new Filter({
children: filterObj,
is_group: true,
logical_op: 'and',
}),
];
if (args.viewId) {
conditionObj.push(
new Filter({ new Filter({
children: filterObj, children:
(await Filter.rootFilterList({ viewId: args.viewId })) || [],
is_group: true, is_group: true,
logical_op: 'and',
}), }),
], );
qb, }
this.dbDriver,
); await conditionV2(conditionObj, qb, this.dbDriver);
qb.update(updateData); qb.update(updateData);

7
packages/nocodb/src/schema/swagger.json

@ -10059,6 +10059,13 @@
}, },
"in": "query", "in": "query",
"name": "where" "name": "where"
},
{
"schema": {
"type": "string"
},
"in": "query",
"name": "viewId"
} }
], ],
"patch": { "patch": {

Loading…
Cancel
Save