@aicore/cocodb-ws-client 1.0.14 → 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 +8 -8
- package/src/index.js +2 -1
- package/src/utils/api.js +31 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aicore/cocodb-ws-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "Websocket client for cocoDb",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -47,23 +47,23 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/aicore/cocoDbWsClient#readme",
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@commitlint/cli": "17.4.
|
|
51
|
-
"@commitlint/config-conventional": "17.4.
|
|
50
|
+
"@commitlint/cli": "17.4.4",
|
|
51
|
+
"@commitlint/config-conventional": "17.4.4",
|
|
52
52
|
"c8": "7.13.0",
|
|
53
53
|
"chai": "4.3.7",
|
|
54
54
|
"cli-color": "2.0.3",
|
|
55
55
|
"documentation": "14.0.1",
|
|
56
|
-
"eslint": "8.
|
|
57
|
-
"glob": "
|
|
56
|
+
"eslint": "8.36.0",
|
|
57
|
+
"glob": "9.3.0",
|
|
58
58
|
"husky": "8.0.3",
|
|
59
59
|
"mocha": "10.2.0"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@aicore/libcommonutils": "1.0.
|
|
63
|
-
"ws": "8.
|
|
62
|
+
"@aicore/libcommonutils": "1.0.20",
|
|
63
|
+
"ws": "8.13.0"
|
|
64
64
|
},
|
|
65
65
|
"optionalDependencies": {
|
|
66
66
|
"bufferutil": "4.0.7",
|
|
67
|
-
"utf-8-validate": "6.0.
|
|
67
|
+
"utf-8-validate": "6.0.3"
|
|
68
68
|
}
|
|
69
69
|
}
|
package/src/index.js
CHANGED
package/src/utils/api.js
CHANGED
|
@@ -219,9 +219,11 @@ export function getFromNonIndex(tableName, queryObject = {}, options= {}) {
|
|
|
219
219
|
* > This function deletes a document from a table
|
|
220
220
|
* @param {string} tableName - The name of the table you want to delete the document from.
|
|
221
221
|
* @param {string} documentId - The id of the document to delete.
|
|
222
|
+
* @param {string} [condition] - Optional coco query condition of the form "$.cost<35" that must be satisfied
|
|
223
|
+
* for delete to happen. See query API for more details on how to write coco query strings.
|
|
222
224
|
* @returns {Promise} A promise.
|
|
223
225
|
*/
|
|
224
|
-
export function deleteDocument(tableName, documentId) {
|
|
226
|
+
export function deleteDocument(tableName, documentId, condition) {
|
|
225
227
|
if (isStringEmpty(tableName)) {
|
|
226
228
|
throw new Error('Please provide valid table name');
|
|
227
229
|
}
|
|
@@ -233,11 +235,38 @@ export function deleteDocument(tableName, documentId) {
|
|
|
233
235
|
fn: COCO_DB_FUNCTIONS.deleteDocument,
|
|
234
236
|
request: {
|
|
235
237
|
tableName: tableName,
|
|
236
|
-
documentId: documentId
|
|
238
|
+
documentId: documentId,
|
|
239
|
+
condition
|
|
237
240
|
}
|
|
238
241
|
});
|
|
239
242
|
}
|
|
240
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
|
+
|
|
241
270
|
/**
|
|
242
271
|
* > This function deletes a table from the database
|
|
243
272
|
* @param {string} tableName - The name of the table to delete.
|