@keltoi/hydra 2.0.5 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +12 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -88,6 +88,10 @@ class Entity{
|
|
|
88
88
|
static fromResult(result=new Result()){
|
|
89
89
|
if(result.isError) return Promise.reject(result)
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
static collectionfromResult(result=new Result()){
|
|
93
|
+
if(result.isError) return Promise.reject(result)
|
|
94
|
+
}
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
class Model {
|
|
@@ -466,14 +470,20 @@ let Repository$1 = class Repository{
|
|
|
466
470
|
this.myContext()
|
|
467
471
|
.where(entity.key)
|
|
468
472
|
.update(entity.data)
|
|
469
|
-
.then(affected=>
|
|
473
|
+
.then(affected=> affected > 0
|
|
474
|
+
? new Result({ code:200,message:`${this.#name} updated` })
|
|
475
|
+
: new Result({ code:404,message:'Not found' })
|
|
476
|
+
)
|
|
470
477
|
.catch(err=>Promise.reject( new Result({code:500,message:err}) ))
|
|
471
478
|
|
|
472
479
|
delete = (entity = new Entity())=>
|
|
473
480
|
this.myContext()
|
|
474
481
|
.where(entity.key)
|
|
475
482
|
.del()
|
|
476
|
-
.then(affected=>
|
|
483
|
+
.then(affected=> affected > 0
|
|
484
|
+
? new Result({ code:200,message:`${this.#name} deleted` })
|
|
485
|
+
: new Result({ code:404,message:'Not found' })
|
|
486
|
+
)
|
|
477
487
|
.catch(err=>Promise.reject( new Result({code:500,message:err}) ))
|
|
478
488
|
|
|
479
489
|
get = (entity = new Entity())=>
|