@aicore/cocodb-ws-client 1.0.6 → 1.0.7
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 +2 -2
- package/src/utils/api.js +37 -1
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.7",
|
|
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.0.0"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@aicore/libcommonutils": "1.0.
|
|
62
|
+
"@aicore/libcommonutils": "1.0.19",
|
|
63
63
|
"ws": "8.9.0"
|
|
64
64
|
},
|
|
65
65
|
"optionalDependencies": {
|
package/src/utils/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {sendMessage} from "./client.js";
|
|
2
2
|
|
|
3
3
|
export {init, close} from "./client.js";
|
|
4
|
-
import {COCO_DB_FUNCTIONS, isObjectEmpty, isStringEmpty} from "@aicore/libcommonutils";
|
|
4
|
+
import {COCO_DB_FUNCTIONS, isObjectEmpty, isString, isStringEmpty} from "@aicore/libcommonutils";
|
|
5
5
|
|
|
6
6
|
// @INCLUDE_IN_API_DOCS
|
|
7
7
|
|
|
@@ -301,3 +301,39 @@ export function update(tableName, documentId, document) {
|
|
|
301
301
|
}
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* It queries the database for a given table name and query string.
|
|
307
|
+
* @param {string} tableName - The name of the table you want to query.
|
|
308
|
+
* @param {string} queryString - The query string to be executed.
|
|
309
|
+
* @param {Array<string>}[useIndexForFields=null] - This is an array of fields that you want to use the index for.
|
|
310
|
+
* @returns {Promise}A promise
|
|
311
|
+
*/
|
|
312
|
+
export function query(tableName, queryString, useIndexForFields = null) {
|
|
313
|
+
if (isStringEmpty(tableName)) {
|
|
314
|
+
throw new Error('Please provide valid table name');
|
|
315
|
+
}
|
|
316
|
+
if (!isString(queryString) || isStringEmpty(queryString)) {
|
|
317
|
+
throw new Error('Please provide valid query String');
|
|
318
|
+
}
|
|
319
|
+
if (!useIndexForFields) {
|
|
320
|
+
return sendMessage(
|
|
321
|
+
{
|
|
322
|
+
fn: COCO_DB_FUNCTIONS.query,
|
|
323
|
+
request: {
|
|
324
|
+
tableName: tableName,
|
|
325
|
+
queryString: queryString
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
return sendMessage(
|
|
330
|
+
{
|
|
331
|
+
fn: COCO_DB_FUNCTIONS.query,
|
|
332
|
+
request: {
|
|
333
|
+
tableName: tableName,
|
|
334
|
+
queryString: queryString,
|
|
335
|
+
useIndexForFields: useIndexForFields
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|