@aicore/cocodb-ws-client 1.0.15 → 1.0.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicore/cocodb-ws-client",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "Websocket client for cocoDb",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -59,7 +59,7 @@
59
59
  "mocha": "10.2.0"
60
60
  },
61
61
  "dependencies": {
62
- "@aicore/libcommonutils": "1.0.19",
62
+ "@aicore/libcommonutils": "1.0.20",
63
63
  "ws": "8.13.0"
64
64
  },
65
65
  "optionalDependencies": {
package/src/index.js CHANGED
@@ -25,6 +25,7 @@ export {
25
25
  put,
26
26
  mathAdd,
27
27
  deleteDocument,
28
+ deleteDocuments,
28
29
  deleteDb,
29
30
  getFromIndex,
30
31
  createIndex,
@@ -80,4 +81,4 @@ export {
80
81
  * await db.close();
81
82
  * ```
82
83
  * @module @aicore/cocodb-ws-client
83
- */
84
+ */
package/src/utils/api.js CHANGED
@@ -241,6 +241,32 @@ export function deleteDocument(tableName, documentId, condition) {
241
241
  });
242
242
  }
243
243
 
244
+ /**
245
+ * > This function deletes all documents satisfying query condition from a table
246
+ * @param {string} tableName - The name of the table in which the key is to be deleted.
247
+ * @param {string} queryString - The cocDB query string.
248
+ * @param {Array[string]} useIndexForFields - List of indexed fields in the document.
249
+ * @returns {Promise} A promise.
250
+ */
251
+ export function deleteDocuments(tableName, queryString, useIndexForFields = []) {
252
+ if (isStringEmpty(tableName)) {
253
+ throw new Error('Please provide valid table name');
254
+ }
255
+ if (isStringEmpty(queryString)) {
256
+ throw new Error('Please provide valid queryString');
257
+ }
258
+ return sendMessage(
259
+ {
260
+ fn: COCO_DB_FUNCTIONS.deleteDocuments,
261
+ request: {
262
+ tableName,
263
+ queryString,
264
+ useIndexForFields
265
+ }
266
+ });
267
+ }
268
+
269
+
244
270
  /**
245
271
  * > This function deletes a table from the database
246
272
  * @param {string} tableName - The name of the table to delete.