From 92b3c94db701b79aa33c7f93435290e599ffafd2 Mon Sep 17 00:00:00 2001 From: Tben Date: Tue, 8 Aug 2023 15:55:27 +0100 Subject: [PATCH] Updates --- package.json | 2 +- utils/get.js | 5 +++-- utils/post.js | 6 +++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index bd1063d..467100d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.3.8", + "version": "1.3.9", "description": "Cloud-based SQL data management tool", "main": "index.js", "scripts": { diff --git a/utils/get.js b/utils/get.js index 4b4810c..0f7cc75 100644 --- a/utils/get.js +++ b/utils/get.js @@ -28,10 +28,11 @@ const https = require("https"); * @param {string} params.db - Database Name * @param {string} params.query - SQL Query * @param {string[]} [params.queryValues] - An array of query values if using "?" placeholders + * @param {string} [params.tableName] - Name of the table to query * * @returns { Promise } - Return Object */ -async function get({ key, db, query, queryValues }) { +async function get({ key, db, query, queryValues, tableName }) { /** * Make https request * @@ -44,7 +45,7 @@ async function get({ key, db, query, queryValues }) { .replace(/ /g, "+")}`; if (queryValues) { - path += `&queryValues=${JSON.stringify(queryValues)}`; + path += `&queryValues=${JSON.stringify(queryValues)}${tableName ? `&tableName=${tableName}` : ""}}`; } https diff --git a/utils/post.js b/utils/post.js index 28b5d80..0fafb90 100644 --- a/utils/post.js +++ b/utils/post.js @@ -1,3 +1,5 @@ +// @ts-check + /** * Imports */ @@ -42,10 +44,11 @@ const https = require("https"); * @param {string} params.database - Database Name * @param {PostDataPayload | string} params.query - SQL query String or Request Object * @param {any[]} [params.queryValues] - Query Values if using "?" placeholders + * @param {string} [params.tableName] - Name of the table to query * * @returns { Promise } - Return Object */ -async function post({ key, query, queryValues, database }) { +async function post({ key, query, queryValues, database, tableName }) { /** * Make https request * @@ -56,6 +59,7 @@ async function post({ key, query, queryValues, database }) { query, queryValues, database, + tableName, }).replace(/\n|\r|\n\r/gm, ""); try {