From b75e95dce0b83594366ca9fcaa5802aa84a4b741 Mon Sep 17 00:00:00 2001 From: Dependency_Bot Date: Mon, 29 Jul 2024 23:06:05 +0000 Subject: [PATCH 1/3] Dependency_Bot: auto-update 97d08dfd --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 803b55d..4cdedb7 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ }, "license": "BSD-3-Clause", "dependencies": { - "@grandlinex/core": "0.32.0", + "@grandlinex/core": "1.0.0", "better-sqlite3": "10.0.0", "@types/better-sqlite3": "7.6.10" }, From 9cb0f9caf518d65dd0b4022b2e7aacf7d4a757b7 Mon Sep 17 00:00:00 2001 From: Dependency_Bot Date: Mon, 29 Jul 2024 23:06:05 +0000 Subject: [PATCH 2/3] 1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4cdedb7..5ebc816 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@grandlinex/bundle-sqlight", - "version": "0.32.1", + "version": "1.0.0", "description": "", "type": "module", "exports": { From 894f480d677f641cb7e5da73135ae2ca82a1ed4b Mon Sep 17 00:00:00 2001 From: David Nagy Date: Tue, 30 Jul 2024 05:56:12 +0200 Subject: [PATCH 3/3] 1.0.0 Upgrade package deps --- package.json | 24 ++++++++++---------- src/class/SQLCon.ts | 54 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 5ebc816..624919b 100644 --- a/package.json +++ b/package.json @@ -46,31 +46,31 @@ "license": "BSD-3-Clause", "dependencies": { "@grandlinex/core": "1.0.0", - "better-sqlite3": "10.0.0", - "@types/better-sqlite3": "7.6.10" + "better-sqlite3": "11.1.2", + "@types/better-sqlite3": "7.6.11" }, "devDependencies": { "@types/jest": "29.5.12", - "@types/node": "20.12.12", - "@typescript-eslint/eslint-plugin": "7.11.0", - "@typescript-eslint/parser": "7.11.0", + "@types/node": "22.0.0", + "@typescript-eslint/eslint-plugin": "7.18.0", + "@typescript-eslint/parser": "7.18.0", "cross-env": "7.0.3", "eslint": "8.57.0", "eslint-config-airbnb": "19.0.4", "eslint-config-airbnb-typescript": "18.0.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-import": "2.29.1", - "eslint-plugin-jest": "28.5.0", - "eslint-plugin-jsx-a11y": "6.8.0", - "eslint-plugin-prettier": "5.1.3", + "eslint-plugin-jest": "28.6.0", + "eslint-plugin-jsx-a11y": "6.9.0", + "eslint-plugin-prettier": "5.2.1", "jest": "29.7.0", "jest-junit": "16.0.0", - "prettier": "3.2.5", - "ts-jest": "29.1.4", + "prettier": "3.3.3", + "ts-jest": "29.1.5", "ts-loader": "9.5.1", "ts-node": "10.9.2", - "typedoc": "0.25.13", - "typescript": "5.4.5" + "typedoc": "0.26.5", + "typescript": "5.5.4" }, "repository": { "type": "git", diff --git a/src/class/SQLCon.ts b/src/class/SQLCon.ts index bb8a589..3f00baa 100644 --- a/src/class/SQLCon.ts +++ b/src/class/SQLCon.ts @@ -13,6 +13,7 @@ import { ICoreKernelModule, ICorePresenter, IDataBase, + IEntity, QueryInterface, RawQuery, } from '@grandlinex/core'; @@ -93,6 +94,24 @@ export default class SQLCon< return result[0] !== null; } + async updateBulkEntity( + config: EntityConfig, + e_id: string[], + entity: EUpDateProperties, + ): Promise { + const [, values, params] = objToTable(entity, config, true); + const result = await this.execScripts([ + { + exec: `UPDATE ${this.schemaName}.${config.className} + SET ${values.join(', ')} + WHERE e_id in (${e_id.map(() => '?').join(',')});`, + param: [...params, ...e_id], + }, + ]); + + return result[0] !== null; + } + async getEntityById( config: EntityConfig, id: string, @@ -110,6 +129,23 @@ export default class SQLCon< return null; } + async getEntityBulkById( + config: EntityConfig, + e_id: string[], + ): Promise { + const query = this.db?.prepare( + `SELECT * + FROM ${this.schemaName}.${config.className} + WHERE e_id in (${e_id.map(() => '?').join(',')});`, + ); + + const res = query?.all(e_id); + if (res) { + return tableToObj(config, res); + } + return []; + } + async findEntity( config: EntityConfig, search: { [D in keyof E]?: E[D] | undefined }, @@ -140,6 +176,18 @@ export default class SQLCon< return query?.run([id]).changes === 1; } + async deleteEntityBulkById( + className: string, + e_id: string[], + ): Promise { + const query = this.db?.prepare( + `DELETE + FROM ${this.schemaName}.${className} + WHERE e_id in (${e_id.map(() => '?').join(',')});`, + ); + return (query?.run([...e_id]).changes ?? 0) > 1; + } + async getEntityList( q: QueryInterface, ): Promise { @@ -164,9 +212,9 @@ export default class SQLCon< } const query = this.db?.prepare( `SELECT * - FROM ${this.schemaName}.${config.className} - ${searchQ} - ${orderByQ} + FROM ${this.schemaName}.${config.className} + ${searchQ} + ${orderByQ} ${range};`, );