@keltoi/hydra 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keltoi/hydra",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Boilerplate to start your API from zero using Repository Pattern",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,4 +9,8 @@ export default class Model{
9
9
 
10
10
  get entity(){return {}}
11
11
 
12
+ static build(key={}){
13
+ return new Model(key)
14
+ }
15
+
12
16
  }
@@ -18,7 +18,6 @@ export default class Repository{
18
18
  return array.length ? array.map(modeling) : []
19
19
  }
20
20
 
21
-
22
21
  constructor(model=Model,context=new Context())
23
22
  {
24
23
  this.#name = model.name
@@ -26,7 +25,7 @@ export default class Repository{
26
25
  this.resetContext=()=>{
27
26
  this.myContext=()=>context.db(this.#name)
28
27
  }
29
- this.modelInstance=(m={})=>new model(m)
28
+ this.modelInstance=(m={})=>model.build(m)
30
29
  }
31
30
 
32
31
  set context(value=knex()){ this.myContext=()=>value(this.#name)}