@keltoi/hydra 2.0.12 → 2.2.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.
Files changed (2) hide show
  1. package/index.js +23 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -159,6 +159,7 @@ class Linking{
159
159
  )
160
160
  }
161
161
 
162
+ static migrations(){ return [] }
162
163
 
163
164
  get abscissaKey(){
164
165
  return { idAbscissa: this.#abscissa.key }
@@ -439,6 +440,8 @@ let Repository$1 = class Repository{
439
440
 
440
441
  myContext
441
442
 
443
+ get name(){ return this.#name }
444
+
442
445
  constructor(entity=Entity,context=new Context$2())
443
446
  {
444
447
  this.#name = entity.name;
@@ -514,6 +517,26 @@ class ChangeableRepository extends Repository$1{
514
517
  super(entity,context);
515
518
  }
516
519
 
520
+ reactive = (entity = new Changeable())=>
521
+ this.myContext()
522
+ .where(entity.key)
523
+ .update({active:true})
524
+ .then(affected=> affected > 0
525
+ ? new Result({ code:200,data:`${this.name} updated` })
526
+ : new Result({ code:404,message:'Not found' })
527
+ )
528
+ .catch(err=>Promise.reject( new Result({code:500,message:err}) ))
529
+
530
+ remove = (entity = new Changeable())=>
531
+ this.myContext()
532
+ .where(entity.key)
533
+ .update({active:false})
534
+ .then(affected=> affected > 0
535
+ ? new Result({ code:200,data:`${this.name} updated` })
536
+ : new Result({ code:404,message:'Not found' })
537
+ )
538
+ .catch(err=>Promise.reject( new Result({code:500,message:err}) ))
539
+
517
540
  deceased = (order = 'asc') =>
518
541
  this.myContext()
519
542
  .where({active:false})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keltoi/hydra",
3
- "version": "2.0.12",
3
+ "version": "2.2.0",
4
4
  "description": "Boilerplate to start your API from zero using Repository Pattern",
5
5
  "main": "index.js",
6
6
  "module": "index.js",