Skip to content

Commit 816ebd9

Browse files
Database constructor will take optional mode parameters
1 parent d327257 commit 816ebd9

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sqlitecloud-js",
3-
"version": "0.0.24",
3+
"version": "0.0.25",
44
"description": "SQLiteCloud drivers for Typescript/Javascript in edge, web and node clients",
55
"main": "./lib/index.js",
66
"types": "./lib/index.d.ts",

src/database.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,21 @@ import EventEmitter from 'eventemitter3'
2929
*/
3030
export class Database extends EventEmitter {
3131
/** Create and initialize a database from a full configuration object, or connection string */
32-
constructor(config: SQLiteCloudConfig | string, callback?: ErrorCallback) {
32+
constructor(config: SQLiteCloudConfig | string, callback?: ErrorCallback)
33+
constructor(config: SQLiteCloudConfig | string, mode?: number, callback?: ErrorCallback)
34+
constructor(config: SQLiteCloudConfig | string, mode?: number | ErrorCallback, callback?: ErrorCallback) {
3335
super()
3436
this.config = typeof config === 'string' ? { connectionString: config } : config
37+
38+
// mode is optional and so is callback
39+
// https://github.com/TryGhost/node-sqlite3/wiki/API#new-sqlite3databasefilename--mode--callback
40+
if (typeof mode === 'function') {
41+
callback = mode
42+
mode = undefined
43+
}
44+
45+
// mode is ignored for now
46+
3547
// opens first connection to the database automatically
3648
this.getConnection(callback as ResultsCallback)
3749
}

0 commit comments

Comments
 (0)