This commit is contained in:
Tben 2023-05-14 10:03:32 +01:00
parent b2fe996bdd
commit 84bdfbe6f1
4 changed files with 14 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "datasquirel", "name": "datasquirel",
"version": "1.1.3", "version": "1.1.4",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -18,7 +18,7 @@ const https = require("https");
* ============================================================================== * ==============================================================================
* @param {String} key - API Key * @param {String} key - API Key
* @param {String} database - Target Database * @param {String} database - Target Database
* @param {String | Object} payload - SQL query String or Request Object. Eg. { * @param {String | Object} payload - User Object. Eg. {
first_name: "Benjamin", first_name: "Benjamin",
last_name:"Toby", last_name:"Toby",
email:"benoti.san@gmail.com", email:"benoti.san@gmail.com",

View File

@ -18,7 +18,8 @@ const https = require("https");
* ============================================================================== * ==============================================================================
* @param {String} key - API Key * @param {String} key - API Key
* @param {String} database - Target Database * @param {String} database - Target Database
* @param {String | Object} payload - SQL query String or Request Object. Eg. { * @param {String | Object} payload - User Object. Eg. {
id: 3, ****Required
first_name: "Benjamin", first_name: "Benjamin",
last_name:"Toby", last_name:"Toby",
email:"benoti.san@gmail.com", email:"benoti.san@gmail.com",

View File

@ -17,7 +17,8 @@ const https = require("https");
* Main Function * Main Function
* ============================================================================== * ==============================================================================
* @param {String} key - API Key * @param {String} key - API Key
* @param {String | Object} payload - SQL query String or Request Object. Eg. { * @param {String} database - Database Name
* @param {String | Object} query - SQL query String or Request Object. Eg. {
action: "insert | update | delete", action: "insert | update | delete",
data: { data: {
user_id: user.id, user_id: user.id,
@ -25,16 +26,22 @@ const https = require("https");
user_last_name: user.last_name, user_last_name: user.last_name,
}, },
table: "posts", table: "posts",
identifierColumnName: "id",
identifierValue: 1,
condition: "WHERE likes > 2"
} }
*/ */
module.exports = async function ({ key, payload }) { module.exports = async function ({ key, query, database }) {
/** /**
* 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) => {
const reqPayload = JSON.stringify(payload); const reqPayload = JSON.stringify({
query,
database,
});
const httpsRequest = https.request( const httpsRequest = https.request(
{ {