@keltoi/hydra 2.0.12 → 2.1.0
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 +22 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -439,6 +439,8 @@ let Repository$1 = class Repository{
|
|
|
439
439
|
|
|
440
440
|
myContext
|
|
441
441
|
|
|
442
|
+
get name(){ return this.#name }
|
|
443
|
+
|
|
442
444
|
constructor(entity=Entity,context=new Context$2())
|
|
443
445
|
{
|
|
444
446
|
this.#name = entity.name;
|
|
@@ -514,6 +516,26 @@ class ChangeableRepository extends Repository$1{
|
|
|
514
516
|
super(entity,context);
|
|
515
517
|
}
|
|
516
518
|
|
|
519
|
+
reactive = (entity = new Changeable())=>
|
|
520
|
+
this.myContext()
|
|
521
|
+
.where(entity.key)
|
|
522
|
+
.update({active:true})
|
|
523
|
+
.then(affected=> affected > 0
|
|
524
|
+
? new Result({ code:200,data:`${this.name} updated` })
|
|
525
|
+
: new Result({ code:404,message:'Not found' })
|
|
526
|
+
)
|
|
527
|
+
.catch(err=>Promise.reject( new Result({code:500,message:err}) ))
|
|
528
|
+
|
|
529
|
+
remove = (entity = new Changeable())=>
|
|
530
|
+
this.myContext()
|
|
531
|
+
.where(entity.key)
|
|
532
|
+
.update({active:false})
|
|
533
|
+
.then(affected=> affected > 0
|
|
534
|
+
? new Result({ code:200,data:`${this.name} updated` })
|
|
535
|
+
: new Result({ code:404,message:'Not found' })
|
|
536
|
+
)
|
|
537
|
+
.catch(err=>Promise.reject( new Result({code:500,message:err}) ))
|
|
538
|
+
|
|
517
539
|
deceased = (order = 'asc') =>
|
|
518
540
|
this.myContext()
|
|
519
541
|
.where({active:false})
|