@keltoi/hydra 2.0.1 → 2.0.3

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 +10 -17
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -448,13 +448,13 @@ let Repository$1 = class Repository{
448
448
 
449
449
  set context(value=knex()){ this.myContext=()=>value(this.#name); }
450
450
 
451
- create = (entity = new Entity())=>
451
+ insert = (entity = new Entity())=>
452
452
  this.myContext()
453
453
  .insert(entity.$)
454
454
  .then(()=>new Result({data:entity}))
455
455
  .catch(err=>Promise.reject( new Result({code:500,message:err}) ))
456
456
 
457
- insert = (entity = new Entity())=>
457
+ create = (entity = new Entity())=>
458
458
  this.myContext()
459
459
  .insert(entity.data,Object.keys(entity.key))
460
460
  .then(ids=>new Result({
@@ -633,7 +633,7 @@ class DbLinked {
633
633
  this.#linking = link;
634
634
  }
635
635
 
636
- createBatch = (linkings=[ new Linking() ])=>
636
+ insertBatch = (linkings=[ new Linking() ])=>
637
637
  this.myContext()
638
638
  .insert(
639
639
  linkings.map(l => (
@@ -646,7 +646,7 @@ class DbLinked {
646
646
  .then(()=>new Result({data:linkings}))
647
647
  .catch(err=>Promise.reject(new Result({code:500,message:err})));
648
648
 
649
- create = (linked=new Linking())=>
649
+ insert = (linked=new Linking())=>
650
650
  this.myContext()
651
651
  .insert({
652
652
  ...linked.key,
@@ -662,7 +662,7 @@ class DbLinked {
662
662
  .build({abscissa,ordinate:o})
663
663
  );
664
664
 
665
- return this.createBatch(batch);
665
+ return this.insertBatch(batch);
666
666
  }
667
667
 
668
668
  insertAbscissasByOrdinate = ({ ordinate=new Entity(),abscissas=[new Entity()] })=>{
@@ -671,7 +671,7 @@ class DbLinked {
671
671
  .build({abscissa:a,ordinate})
672
672
  );
673
673
 
674
- return this.createBatch(batch)
674
+ return this.insertBatch(batch)
675
675
  }
676
676
 
677
677
  delete = (linked=new Linking())=>
@@ -771,7 +771,7 @@ let Context$1 = class Context{
771
771
  class Repository {
772
772
  #context
773
773
 
774
- constructor(entity=Entity,context=new Context$1()){
774
+ constructor(context=new Context$1()){
775
775
  this.#context = context;
776
776
  }
777
777
 
@@ -785,8 +785,8 @@ class Repository {
785
785
  }
786
786
 
787
787
  class RestfulRepository extends Repository{
788
- constructor(entity = Entity,context=new Context$1()){
789
- super(entity,context);
788
+ constructor(context=new Context$1()){
789
+ super(context);
790
790
  }
791
791
 
792
792
  #keysAsParams(route='',key={}){
@@ -815,13 +815,6 @@ class RestfulRepository extends Repository{
815
815
  : Promise.reject(new Result({code:value.status, message:value.statusText}));
816
816
  })
817
817
 
818
- list=(route='',query={}|undefined)=>this.#httpGet(route,query)
819
- .then(value=>{
820
- value.status === 200
821
- ? new Result({data:value.data})
822
- : Promise.reject(new Result({code:value.status, message:value.statusText}));
823
- })
824
-
825
818
  create=(route='',entity=new Entity())=>this.context
826
819
  .http
827
820
  .post(route,entity.data)
@@ -857,7 +850,7 @@ class RestfulRepository extends Repository{
857
850
  })
858
851
  }
859
852
 
860
- delete=(id,entity = new Entity())=>{
853
+ delete=(route='',entity = new Entity())=>{
861
854
  const url = this.#keysAsParams(route,entity.key);
862
855
 
863
856
  return this.context
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keltoi/hydra",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Boilerplate to start your API from zero using Repository Pattern",
5
5
  "main": "index.js",
6
6
  "module": "index.js",