@saltcorn/postgres 1.1.0-beta.9 → 1.1.1-beta.0

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/postgres.js +10 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/postgres",
3
- "version": "1.1.0-beta.9",
3
+ "version": "1.1.1-beta.0",
4
4
  "description": "Postgres structures for Saltcorn, open-source no-code platform",
5
5
  "homepage": "https://saltcorn.com",
6
6
  "scripts": {
@@ -12,7 +12,7 @@
12
12
  "license": "MIT",
13
13
  "main": "index.js",
14
14
  "dependencies": {
15
- "@saltcorn/db-common": "1.1.0-beta.9",
15
+ "@saltcorn/db-common": "1.1.1-beta.0",
16
16
  "pg": "^8.2.1",
17
17
  "pg-copy-streams": "^5.1.1",
18
18
  "replacestream": "4.0.3"
package/postgres.js CHANGED
@@ -201,6 +201,15 @@ const deleteWhere = async (tbl, whereObj, opts = Object.create(null)) => {
201
201
  return tq.rows;
202
202
  };
203
203
 
204
+ const truncate = async (tbl) => {
205
+ const sql = `truncate "${getTenantSchema()}"."${sqlsanitize(tbl)}"`;
206
+ sql_log(sql, []);
207
+
208
+ const tq = await (client || pool).query(sql, []);
209
+
210
+ return tq.rows;
211
+ };
212
+
204
213
  /**
205
214
  * Insert rows into table
206
215
  * @param {string} tbl - table name
@@ -537,6 +546,7 @@ const postgresExports = {
537
546
  listTables,
538
547
  listScTables,
539
548
  listUserDefinedTables,
549
+ truncate,
540
550
  };
541
551
 
542
552
  module.exports = (getConnectObjectPara) => {