Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoBorzi committed Feb 26, 2020
1 parent 48f40b5 commit 5e43fb3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/app/main/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class AppComponent implements OnInit {
}
});

/* istanbul ignore next */
this.sqliteQueryService.query('SELECT * FROM achievements WHERE id = 42').subscribe((result) => {

});
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/services/sqlite-query.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SqliteService } from '@keira-shared/services/sqlite.service';
import { ConfigService } from '@keira-shared/services/config.service';
import { TableRow } from '@keira-types/general';

/* istanbul ignore next */ // Note: will be tested in e2e
@Injectable({
providedIn: 'root'
})
Expand Down
9 changes: 5 additions & 4 deletions src/app/shared/services/sqlite.service.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { Injectable, NgZone } from '@angular/core';
import { Database, OPEN_READONLY } from 'sqlite3';
import { Observable } from 'rxjs';
import { AppConfig } from '../../../environments/environment';
import { ElectronService } from '@keira-shared/services/electron.service';
import { AppConfig } from '../../../environments/environment';
import { TableRow } from '@keira-types/general';

/* istanbul ignore next */ // Note: will be tested in e2e
@Injectable({
providedIn: 'root'
})
export class SqliteService {

private db: Database;
private db;

constructor(
private electronService: ElectronService,
private ngZone: NgZone,
) {
/* istanbul ignore next */
if (this.electronService.isElectron()) {
this.db = new Database(AppConfig.sqlitePath, OPEN_READONLY, (error) => {
const sqlite = window.require('sqlite3');
this.db = new sqlite.Database(AppConfig.sqlitePath, sqlite.OPEN_READONLY, (error) => {
if (error) {
console.log(`Error when opening sqlite database at ${AppConfig.sqlitePath}`);
console.error(error);
Expand Down

0 comments on commit 5e43fb3

Please sign in to comment.