From a01dd7107b5043f683913c1ae16086f0bb396893 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Tue, 12 Nov 2024 12:01:39 +0100 Subject: [PATCH] Add Insert Generator --- functions/sql/sql-insert-generator.d.ts | 24 ++++++++++++++++++++++++ index.d.ts | 2 ++ index.js | 2 ++ package.json | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 functions/sql/sql-insert-generator.d.ts diff --git a/functions/sql/sql-insert-generator.d.ts b/functions/sql/sql-insert-generator.d.ts new file mode 100644 index 0000000..1f3d34c --- /dev/null +++ b/functions/sql/sql-insert-generator.d.ts @@ -0,0 +1,24 @@ +export = sqlInsertGenerator; +/** + * @typedef {object} SQLINsertGenReturn + * @property {string} query + * @property {string[]} values + */ +/** + * @param {object} param0 + * @param {any[]} param0.data + * @param {string} param0.tableName + * + * @return {SQLINsertGenReturn | undefined} + */ +declare function sqlInsertGenerator({ tableName, data }: { + data: any[]; + tableName: string; +}): SQLINsertGenReturn | undefined; +declare namespace sqlInsertGenerator { + export { SQLINsertGenReturn }; +} +type SQLINsertGenReturn = { + query: string; + values: string[]; +}; diff --git a/index.d.ts b/index.d.ts index ed0efae..8a227ed 100644 --- a/index.d.ts +++ b/index.d.ts @@ -26,6 +26,7 @@ import sanitizeSql = require("./utils/functions/sanitizeSql"); import datasquirelClient = require("./client"); export namespace sql { export { sqlGenerator }; + export { sqlInsertGenerator }; } import uploadImage = require("./utils/upload-image"); import uploadFile = require("./utils/upload-file"); @@ -43,4 +44,5 @@ import validateToken = require("./users/validate-token"); import loginWithGoogle = require("./users/social/google-auth"); import loginWithGithub = require("./users/social/github-auth"); import sqlGenerator = require("./functions/sql/sql-generator"); +import sqlInsertGenerator = require("./functions/sql/sql-insert-generator"); export { get, post, getSchema, sanitizeSql, datasquirelClient as client }; diff --git a/index.js b/index.js index 5a9c3e0..5a799da 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,7 @@ const validateToken = require("./users/validate-token"); const sanitizeSql = require("./utils/functions/sanitizeSql"); const datasquirelClient = require("./client"); const sqlGenerator = require("./functions/sql/sql-generator"); +const sqlInsertGenerator = require("./functions/sql/sql-insert-generator"); //////////////////////////////////////// //////////////////////////////////////// @@ -68,6 +69,7 @@ const media = { */ const sql = { sqlGenerator, + sqlInsertGenerator, }; /** diff --git a/package.json b/package.json index 1f0c662..cd07a1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "2.5.9", + "version": "2.6.0", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": {