minor revision
This commit is contained in:
parent
32a28c5b45
commit
4c1b856e55
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "datasquirel",
|
"name": "datasquirel",
|
||||||
"version": "1.1.87",
|
"version": "1.1.88",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
19
utils/get.js
19
utils/get.js
@ -26,17 +26,27 @@ const https = require("https");
|
|||||||
* @param {Object} params - Single object passed
|
* @param {Object} params - Single object passed
|
||||||
* @param {string} params.key - API Key
|
* @param {string} params.key - API Key
|
||||||
* @param {string} params.db - Database Name
|
* @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<GetReturn> } - Return Object
|
* @returns { Promise<GetReturn> } - Return Object
|
||||||
*/
|
*/
|
||||||
async function get({ key, db, query }) {
|
async function get({ key, db, query, queryValues }) {
|
||||||
/**
|
/**
|
||||||
* Make https request
|
* Make https request
|
||||||
*
|
*
|
||||||
* @description make a request to datasquirel.com
|
* @description make a request to datasquirel.com
|
||||||
*/
|
*/
|
||||||
const httpResponse = await new Promise((resolve, reject) => {
|
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
|
https
|
||||||
.request(
|
.request(
|
||||||
{
|
{
|
||||||
@ -47,10 +57,7 @@ async function get({ key, db, query }) {
|
|||||||
},
|
},
|
||||||
port: 443,
|
port: 443,
|
||||||
hostname: "datasquirel.com",
|
hostname: "datasquirel.com",
|
||||||
path: `/api/query/get?db=${db}&query=${query
|
path: path,
|
||||||
.replace(/\n|\r|\n\r/g, "")
|
|
||||||
.replace(/ {2,}/g, " ")
|
|
||||||
.replace(/ /g, "+")}`,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user