Skip to content

Commit

Permalink
Merge pull request #2392 from JeongJun-Lee/feature-sqlcipher-driver
Browse files Browse the repository at this point in the history
[Feature Request] Add new connection option to sqlite for SQLCipher #…
  • Loading branch information
pleerock committed Jun 24, 2018
2 parents b6ee9e4 + ff72246 commit fee8c46
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/driver/sqlite/SqliteConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ export interface SqliteConnectionOptions extends BaseConnectionOptions {
*/
readonly database: string;

/**
* Encryption key for for SQLCipher.
*/
readonly key?: string;

}
8 changes: 8 additions & 0 deletions src/driver/sqlite/SqliteDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ export class SqliteDriver extends AbstractSqliteDriver {
if (err) return fail(err);
ok(databaseConnection);
});

// in the options, if encryption key for for SQLCipher is setted.
if (this.options.key) {
databaseConnection.run(`PRAGMA key = ${this.options.key};`, (err: any, result: any) => {
if (err) return fail(err);
ok(databaseConnection);
});
}
});
});
}
Expand Down

0 comments on commit fee8c46

Please sign in to comment.