Skip to content

Commit e2887bf

Browse files
author
Fernando Leal
committed
versão 0.5.7
1 parent 9cdf7cc commit e2887bf

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "database-builder",
3-
"version": "0.5.6",
3+
"version": "0.5.7",
44
"description": "Library to assist in creating and maintaining SQL commands.",
55
"main": "./src/index.js",
66
"types": "./src/index.d.ts",

src/adapters/sqlite3-database-adapter.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { SQLite3Interface, SQLite3ObjectInterface } from "../definitions/sqlite3
44
import { QueryHelper } from "../core/query-helper";
55
import { BaseDatabaseAdapter } from "./base-database.adapter";
66
import { WebSqlTransactionInterface } from "../definitions/websql-interface";
7+
import { Utils } from "../core/utils";
78

89
/**
910
* Adapter for https://www.npmjs.com/package/sqlite3
@@ -209,16 +210,7 @@ export class SQLite3DatabaseAdapter extends BaseDatabaseAdapter<SQLite3ObjectInt
209210
rowsAffected: number = 0,
210211
insertId: any = void 0
211212
): DatabaseResult {
212-
return {
213-
rows: {
214-
length: rows.length,
215-
item: (index: number) => {
216-
return rows[index];
217-
}
218-
},
219-
rowsAffected,
220-
insertId
221-
} as DatabaseResult;
213+
return Utils.objectToDatabaseResult(rows, rowsAffected, insertId);
222214
}
223215

224216
private beginTransaction(database: SQLite3ObjectInterface): Promise<DatabaseResult> {

src/core/utils.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import * as lodash from "lodash";
2525
import { QueryCompiled } from ".";
2626
import { Resultable } from "./resultable";
2727
import { SqlCompilable } from "../crud/sql-compilable";
28+
import { DatabaseResult } from "../definitions/database-definition";
2829

2930
export type ParamType = ValueType | ReplacementParam;
3031

@@ -469,5 +470,22 @@ export class Utils {
469470

470471
public static getDatabaseHelper(): DatabaseHelper {
471472
return this._databaseHelper = this._databaseHelper ? this._databaseHelper : new DatabaseHelper();
473+
}
474+
475+
public static objectToDatabaseResult(
476+
rows: any[],
477+
rowsAffected: number = 0,
478+
insertId: any = void 0
479+
): DatabaseResult {
480+
return {
481+
rows: {
482+
length: rows.length,
483+
item: (index: number) => {
484+
return rows[index];
485+
}
486+
},
487+
rowsAffected,
488+
insertId
489+
} as DatabaseResult;
472490
}
473491
}

0 commit comments

Comments
 (0)