Skip to content

Commit

Permalink
Fix promise
Browse files Browse the repository at this point in the history
  • Loading branch information
astroanu committed Apr 14, 2019
1 parent ceeadac commit 68d5dc1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/services/db/db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export class DbService implements DbServiceInterface {
update(id: string, value: object): Observable<void> {
return new Observable((observer) => {
this.getDb().subscribe((db: any) => {
db.getByKey(this.storeName, id).subscribe((result) => {
db.getByKey(this.storeName, id).then((result) => {
value[this.primaryKey] = id;

if (result) {
db.update(this.storeName, value).subscribe(() => observer.next(), (e) => observer.error());
db.update(this.storeName, value).then(() => observer.next(), (e) => observer.error());
} else {
db.add(this.storeName, value).subscribe(() => observer.next(), (e) => observer.error());
db.add(this.storeName, value).then(() => observer.next(), (e) => observer.error());
}
});
});
Expand Down

0 comments on commit 68d5dc1

Please sign in to comment.