Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
feat(repository): Added findPath and getResource methods for flexibil…
- Loading branch information
Showing
with
23 additions
and
2 deletions.
-
+23
−2
src/repository.js
|
@@ -27,15 +27,36 @@ export class Repository { |
|
|
return this; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Get the resource name of this repository instance's reference. |
|
|
* |
|
|
* @return {string|null} |
|
|
*/ |
|
|
getResource() { |
|
|
return this.resource; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Perform a find query. |
|
|
* |
|
|
* @param {null|{}|Number} criteria Criteria to add to the query. |
|
|
* @param {boolean} raw Set to true to get a POJO in stead of populated entities. |
|
|
* @param {boolean} [raw] Set to true to get a POJO in stead of populated entities. |
|
|
* @return {*} |
|
|
*/ |
|
|
find(criteria, raw) { |
|
|
let findQuery = this.api.find(this.resource, criteria); |
|
|
return this.findPath(this.resource, criteria, raw); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Perform a find query for `path`. |
|
|
* |
|
|
* @param {string} path |
|
|
@param {null|{}|Number} criteria Criteria to add to the query. |
|
|
* @param {boolean} [raw] Set to true to get a POJO in stead of populated entities. |
|
|
* @return {*} |
|
|
*/ |
|
|
findPath(path, criteria, raw) { |
|
|
let findQuery = this.api.find(path, criteria); |
|
|
|
|
|
if (raw) { |
|
|
return findQuery; |
|
|