Skip to content

Commit

Permalink
1.0.2 Upgrade package deps + fix bulk with empty array as argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Elschnagoo committed Jul 30, 2024
1 parent afd1801 commit cf2a290
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@grandlinex/bundle-sqlight",
"version": "1.0.1",
"version": "1.0.2",
"description": "",
"type": "module",
"exports": {
Expand Down
19 changes: 18 additions & 1 deletion src/class/SQLCon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ export default class SQLCon<
{
db: DbType | null;

printLog: boolean;

private readonly path: string;

constructor(
module: ICoreKernelModule<any, any, any, any, any>,
dbversion: string,
printLog = false,
) {
super(dbversion, 'main', module);
const store = module.getKernel().getConfigStore();
Expand All @@ -55,6 +58,7 @@ export default class SQLCon<
}
this.path = Path.join(path, `${module.getName()}.db`);
this.db = null;
this.printLog = printLog;
}

async createEntity<E extends CoreEntity>(
Expand Down Expand Up @@ -99,6 +103,9 @@ export default class SQLCon<
e_id: string[],
entity: EUpDateProperties<E>,
): Promise<boolean> {
if (e_id.length === 0) {
return false;
}
const [, values, params] = objToTable(entity, config, true);
const result = await this.execScripts([
{
Expand Down Expand Up @@ -133,6 +140,9 @@ export default class SQLCon<
config: EntityConfig<E>,
e_id: string[],
): Promise<E[]> {
if (e_id.length === 0) {
return [];
}
const query = this.db?.prepare(
`SELECT *
FROM ${this.schemaName}.${config.className}
Expand Down Expand Up @@ -180,6 +190,9 @@ export default class SQLCon<
className: string,
e_id: string[],
): Promise<boolean> {
if (e_id.length === 0) {
return false;
}
const query = this.db?.prepare(
`DELETE
FROM ${this.schemaName}.${className}
Expand Down Expand Up @@ -296,7 +309,11 @@ export default class SQLCon<
async connect(): Promise<boolean> {
try {
this.db = new Database(this.path, {
verbose: this.debug,
verbose: (message, additionalArgs) => {
if (this.printLog) {
this.verbose(message, additionalArgs);
}
},
});
} catch (e) {
this.error(e);
Expand Down

0 comments on commit cf2a290

Please sign in to comment.