@keltoi/hydra 2.0.1 → 2.0.2
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 +10 -17
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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(
|
|
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(
|
|
789
|
-
super(
|
|
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=(
|
|
853
|
+
delete=(route='',entity = new Entity())=>{
|
|
861
854
|
const url = this.#keysAsParams(route,entity.key);
|
|
862
855
|
|
|
863
856
|
return this.context
|