From 4c1b856e5597407d68f40a4792980803c09acead Mon Sep 17 00:00:00 2001 From: Tben Date: Wed, 26 Jul 2023 05:04:02 +0100 Subject: [PATCH] minor revision --- package.json | 2 +- utils/get.js | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 16d416a..2c2c940 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.1.87", + "version": "1.1.88", "description": "Cloud-based SQL data management tool", "main": "index.js", "scripts": { diff --git a/utils/get.js b/utils/get.js index fe0e160..4b4810c 100644 --- a/utils/get.js +++ b/utils/get.js @@ -26,17 +26,27 @@ const https = require("https"); * @param {Object} params - Single object passed * @param {string} params.key - API Key * @param {string} params.db - Database Name - * @param {(string | Object)} params.query - SQL Query + * @param {string} params.query - SQL Query + * @param {string[]} [params.queryValues] - An array of query values if using "?" placeholders * * @returns { Promise } - Return Object */ -async function get({ key, db, query }) { +async function get({ key, db, query, queryValues }) { /** * Make https request * * @description make a request to datasquirel.com */ const httpResponse = await new Promise((resolve, reject) => { + let path = `/api/query/get?db=${db}&query=${query + .replace(/\n|\r|\n\r/g, "") + .replace(/ {2,}/g, " ") + .replace(/ /g, "+")}`; + + if (queryValues) { + path += `&queryValues=${JSON.stringify(queryValues)}`; + } + https .request( { @@ -47,10 +57,7 @@ async function get({ key, db, query }) { }, port: 443, hostname: "datasquirel.com", - path: `/api/query/get?db=${db}&query=${query - .replace(/\n|\r|\n\r/g, "") - .replace(/ {2,}/g, " ") - .replace(/ /g, "+")}`, + path: path, }, /**