sedentary-pg 0.0.44 → 0.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/pgdb.js CHANGED
@@ -73,6 +73,22 @@ class PGDB extends sedentary_1.DB {
73
73
  await ret._client.query("BEGIN");
74
74
  return ret;
75
75
  }
76
+ cancel(tableName) {
77
+ return async (where, tx) => {
78
+ const client = tx ? tx._client : await this.pool.connect();
79
+ let rowCount = 0;
80
+ try {
81
+ const query = `DELETE FROM ${tableName}${where ? ` WHERE ${where}` : ""}`;
82
+ this.log(query);
83
+ ({ rowCount } = await client.query(query));
84
+ }
85
+ finally {
86
+ if (!tx)
87
+ client.release();
88
+ }
89
+ return rowCount;
90
+ };
91
+ }
76
92
  async client() {
77
93
  return await this.pool.connect();
78
94
  }
package/dist/es/pgdb.js CHANGED
@@ -68,6 +68,22 @@ export class PGDB extends DB {
68
68
  await ret._client.query("BEGIN");
69
69
  return ret;
70
70
  }
71
+ cancel(tableName) {
72
+ return async (where, tx) => {
73
+ const client = tx ? tx._client : await this.pool.connect();
74
+ let rowCount = 0;
75
+ try {
76
+ const query = `DELETE FROM ${tableName}${where ? ` WHERE ${where}` : ""}`;
77
+ this.log(query);
78
+ ({ rowCount } = await client.query(query));
79
+ }
80
+ finally {
81
+ if (!tx)
82
+ client.release();
83
+ }
84
+ return rowCount;
85
+ };
86
+ }
71
87
  async client() {
72
88
  return await this.pool.connect();
73
89
  }
@@ -12,6 +12,7 @@ export declare class PGDB extends DB<TransactionPG> {
12
12
  end(): Promise<void>;
13
13
  defaultNeq(src: string, value: unknown): boolean;
14
14
  begin(): Promise<TransactionPG>;
15
+ cancel(tableName: string): (where: string, tx?: Transaction) => Promise<number>;
15
16
  client(): Promise<PoolClient>;
16
17
  escape(value: unknown): string;
17
18
  fill(attributes: Record<string, string>, row: Record<string, unknown>, entry: Record<string, unknown>): void;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "@types/pg": "8.6.5",
10
10
  "pg": "8.7.3",
11
11
  "pg-format": "1.0.4",
12
- "sedentary": "0.0.44"
12
+ "sedentary": "0.0.45"
13
13
  },
14
14
  "description": "The ORM which never needs to migrate - PostgreSQL",
15
15
  "engines": {
@@ -47,5 +47,5 @@
47
47
  "test": "jest --no-cache --runInBand"
48
48
  },
49
49
  "types": "./dist/types/index.d.ts",
50
- "version": "0.0.44"
50
+ "version": "0.0.45"
51
51
  }