From 68d5dc142a8a1244889c9092697e913fe75ffaa2 Mon Sep 17 00:00:00 2001 From: Anuradha Date: Sun, 14 Apr 2019 16:57:11 +0530 Subject: [PATCH] Fix promise --- src/services/db/db.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/services/db/db.service.ts b/src/services/db/db.service.ts index 7aa554e..a6771bf 100644 --- a/src/services/db/db.service.ts +++ b/src/services/db/db.service.ts @@ -32,13 +32,13 @@ export class DbService implements DbServiceInterface { update(id: string, value: object): Observable { 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()); } }); });