Skip to content

Commit

Permalink
#35 use promises and #38 decorate errors with boom
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenGorenflo committed Jun 9, 2015
1 parent 22db19a commit c7f7410
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ class Util {
});
};

/**
* Same function as getObjectOf but with a returned promise
* @param keyValue
* @param list
* @returns {any}
*/
retrieveSingleValue = (keyValue:any, list:string) => {
return new Promise((resolve, reject) => {

Expand All @@ -191,6 +197,25 @@ class Util {
})
};

/**
* Query a design document (list) with the given key and returns a promise.
* @param keyValue
* @param list
* @returns {any}
*/
retrieveAllValues = (keyValue:any, list:string) => {
return new Promise((resolve, reject) => {

this.db.list(list, {key: keyValue}, (err, data) => {

if (err) {
return reject(this.boom.wrap(err));
}
resolve(data);
});
})
};

/**
* Create document with Timestamp.
*
Expand Down

0 comments on commit c7f7410

Please sign in to comment.