Browse Source

refactor(nocodb): remove unnecessary comments

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
f1d6f22a40
  1. 23
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

23
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -1890,21 +1890,14 @@ class BaseModelSqlv2 {
rowId = rowId =
response[this.model.primaryKey.title] || response[this.model.primaryKey.title] ||
response[this.model.primaryKey.column_name]; response[this.model.primaryKey.column_name];
await Promise.all(postInsertOps.map((f) => f()));
// if (!trx) { await Promise.all(postInsertOps.map((f) => f()));
// await driver.commit();
// }
await this.afterInsert(response, this.dbDriver, cookie); await this.afterInsert(response, this.dbDriver, cookie);
return response; return response;
} catch (e) { } catch (e) {
console.log(e); console.log(e);
// await this.errorInsert(e, data, trx, cookie);
// if (!trx) {
// await driver.rollback(e);
// }
throw e; throw e;
} }
} }
@ -1932,11 +1925,6 @@ class BaseModelSqlv2 {
for (const data of datas) { for (const data of datas) {
await this.validate(data); await this.validate(data);
} }
// let chunkSize = 50;
//
// if (this.isSqlite && datas[0]) {
// chunkSize = Math.max(1, Math.floor(999 / Object.keys(datas[0]).length));
// }
// fallbacks to `10` if database client is sqlite // fallbacks to `10` if database client is sqlite
// to avoid `too many SQL variables` error // to avoid `too many SQL variables` error
@ -1992,8 +1980,6 @@ class BaseModelSqlv2 {
return res; return res;
} catch (e) { } catch (e) {
if (transaction) transaction.rollback(); if (transaction) transaction.rollback();
// console.log(e);
// await this.errorUpdateb(e, data, null);
throw e; throw e;
} }
} }
@ -2061,7 +2047,6 @@ class BaseModelSqlv2 {
); );
transaction = await this.dbDriver.transaction(); transaction = await this.dbDriver.transaction();
// await this.beforeDeleteb(ids, transaction);
const res = []; const res = [];
for (const d of deleteIds) { for (const d of deleteIds) {
@ -2070,7 +2055,6 @@ class BaseModelSqlv2 {
res.push(d); res.push(d);
} }
} }
// await this.afterDeleteb(res, transaction);
transaction.commit(); transaction.commit();
@ -2080,7 +2064,6 @@ class BaseModelSqlv2 {
} catch (e) { } catch (e) {
if (transaction) transaction.rollback(); if (transaction) transaction.rollback();
console.log(e); console.log(e);
// await this.errorDeleteb(e, ids);
throw e; throw e;
} }
} }
@ -2141,7 +2124,6 @@ class BaseModelSqlv2 {
public async afterInsert(data: any, _trx: any, req): Promise<void> { public async afterInsert(data: any, _trx: any, req): Promise<void> {
await this.handleHooks('After.insert', null, data, req); await this.handleHooks('After.insert', null, data, req);
// if (req?.headers?.['xc-gui']) {
const id = this._extractPksValues(data); const id = this._extractPksValues(data);
await Audit.insert({ await Audit.insert({
fk_model_id: this.model.id, fk_model_id: this.model.id,
@ -2155,7 +2137,6 @@ class BaseModelSqlv2 {
ip: req?.clientIp, ip: req?.clientIp,
user: req?.user?.email, user: req?.user?.email,
}); });
// }
} }
public async afterBulkUpdate(data: any, _trx: any, req): Promise<void> { public async afterBulkUpdate(data: any, _trx: any, req): Promise<void> {
@ -2253,7 +2234,6 @@ class BaseModelSqlv2 {
} }
public async afterDelete(data: any, _trx: any, req): Promise<void> { public async afterDelete(data: any, _trx: any, req): Promise<void> {
// if (req?.headers?.['xc-gui']) {
const id = req?.params?.id; const id = req?.params?.id;
await Audit.insert({ await Audit.insert({
fk_model_id: this.model.id, fk_model_id: this.model.id,
@ -2265,7 +2245,6 @@ class BaseModelSqlv2 {
ip: req?.clientIp, ip: req?.clientIp,
user: req?.user?.email, user: req?.user?.email,
}); });
// }
await this.handleHooks('After.delete', data, null, req); await this.handleHooks('After.delete', data, null, req);
} }

Loading…
Cancel
Save