pure-orm 4.0.0-4 → 4.0.0-5

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 (181) hide show
  1. package/README.md +3 -3
  2. package/coverage/clover.xml +5 -5
  3. package/coverage/coverage-final.json +2 -2
  4. package/coverage/lcov-report/dist/src/factory.js.html +19 -4
  5. package/coverage/lcov-report/dist/src/index.html +1 -1
  6. package/coverage/lcov-report/dist/src/index.js.html +1 -1
  7. package/coverage/lcov-report/dist/test-utils/blog/index.html +1 -1
  8. package/coverage/lcov-report/dist/test-utils/blog/models/article.js.html +1 -1
  9. package/coverage/lcov-report/dist/test-utils/blog/models/article_tag.js.html +1 -1
  10. package/coverage/lcov-report/dist/test-utils/blog/models/index.html +1 -1
  11. package/coverage/lcov-report/dist/test-utils/blog/models/person.js.html +1 -1
  12. package/coverage/lcov-report/dist/test-utils/blog/models/tag.js.html +1 -1
  13. package/coverage/lcov-report/dist/test-utils/blog/orm.js.html +1 -1
  14. package/coverage/lcov-report/dist/test-utils/five/index.html +1 -1
  15. package/coverage/lcov-report/dist/test-utils/five/models/index.html +1 -1
  16. package/coverage/lcov-report/dist/test-utils/five/models/line-item.js.html +1 -1
  17. package/coverage/lcov-report/dist/test-utils/five/models/order.js.html +1 -1
  18. package/coverage/lcov-report/dist/test-utils/five/models/parcel-event.js.html +1 -1
  19. package/coverage/lcov-report/dist/test-utils/five/models/parcel-line-item.js.html +1 -1
  20. package/coverage/lcov-report/dist/test-utils/five/models/parcel.js.html +1 -1
  21. package/coverage/lcov-report/dist/test-utils/five/orm.js.html +1 -1
  22. package/coverage/lcov-report/dist/test-utils/nine/index.html +1 -1
  23. package/coverage/lcov-report/dist/test-utils/nine/models/feature-switch.js.html +1 -1
  24. package/coverage/lcov-report/dist/test-utils/nine/models/index.html +1 -1
  25. package/coverage/lcov-report/dist/test-utils/nine/orm.js.html +1 -1
  26. package/coverage/lcov-report/dist/test-utils/order/index.html +1 -1
  27. package/coverage/lcov-report/dist/test-utils/order/models/index.html +1 -1
  28. package/coverage/lcov-report/dist/test-utils/order/models/line-item.js.html +1 -1
  29. package/coverage/lcov-report/dist/test-utils/order/models/order.js.html +1 -1
  30. package/coverage/lcov-report/dist/test-utils/order/models/product-variant.js.html +1 -1
  31. package/coverage/lcov-report/dist/test-utils/order/models/product.js.html +1 -1
  32. package/coverage/lcov-report/dist/test-utils/order/models/utm-source.js.html +1 -1
  33. package/coverage/lcov-report/dist/test-utils/order/orm.js.html +1 -1
  34. package/coverage/lcov-report/dist/test-utils/order-more/index.html +1 -1
  35. package/coverage/lcov-report/dist/test-utils/order-more/models/actual-product-variant.js.html +1 -1
  36. package/coverage/lcov-report/dist/test-utils/order-more/models/color.js.html +1 -1
  37. package/coverage/lcov-report/dist/test-utils/order-more/models/customer.js.html +1 -1
  38. package/coverage/lcov-report/dist/test-utils/order-more/models/gender.js.html +1 -1
  39. package/coverage/lcov-report/dist/test-utils/order-more/models/index.html +1 -1
  40. package/coverage/lcov-report/dist/test-utils/order-more/models/inventory-level.js.html +1 -1
  41. package/coverage/lcov-report/dist/test-utils/order-more/models/line-item.js.html +1 -1
  42. package/coverage/lcov-report/dist/test-utils/order-more/models/order.js.html +1 -1
  43. package/coverage/lcov-report/dist/test-utils/order-more/models/parcel-event.js.html +1 -1
  44. package/coverage/lcov-report/dist/test-utils/order-more/models/parcel-line-item.js.html +1 -1
  45. package/coverage/lcov-report/dist/test-utils/order-more/models/parcel.js.html +1 -1
  46. package/coverage/lcov-report/dist/test-utils/order-more/models/physical-address.js.html +1 -1
  47. package/coverage/lcov-report/dist/test-utils/order-more/models/product-variant-image.js.html +1 -1
  48. package/coverage/lcov-report/dist/test-utils/order-more/models/product-variant.js.html +1 -1
  49. package/coverage/lcov-report/dist/test-utils/order-more/models/product.js.html +1 -1
  50. package/coverage/lcov-report/dist/test-utils/order-more/models/refund.js.html +1 -1
  51. package/coverage/lcov-report/dist/test-utils/order-more/models/shipment-actual-product-variant.js.html +1 -1
  52. package/coverage/lcov-report/dist/test-utils/order-more/models/shipment.js.html +1 -1
  53. package/coverage/lcov-report/dist/test-utils/order-more/models/size.js.html +1 -1
  54. package/coverage/lcov-report/dist/test-utils/order-more/models/utm-medium.js.html +1 -1
  55. package/coverage/lcov-report/dist/test-utils/order-more/models/utm-source.js.html +1 -1
  56. package/coverage/lcov-report/dist/test-utils/order-more/orm.js.html +1 -1
  57. package/coverage/lcov-report/dist/test-utils/six/index.html +1 -1
  58. package/coverage/lcov-report/dist/test-utils/six/models/customer.js.html +1 -1
  59. package/coverage/lcov-report/dist/test-utils/six/models/index.html +1 -1
  60. package/coverage/lcov-report/dist/test-utils/six/models/line-item.js.html +1 -1
  61. package/coverage/lcov-report/dist/test-utils/six/models/order.js.html +1 -1
  62. package/coverage/lcov-report/dist/test-utils/six/models/parcel-line-item.js.html +1 -1
  63. package/coverage/lcov-report/dist/test-utils/six/models/parcel.js.html +1 -1
  64. package/coverage/lcov-report/dist/test-utils/six/orm.js.html +1 -1
  65. package/coverage/lcov-report/dist/test-utils/thirteen/index.html +1 -1
  66. package/coverage/lcov-report/dist/test-utils/thirteen/models/audience.js.html +1 -1
  67. package/coverage/lcov-report/dist/test-utils/thirteen/models/brand.js.html +1 -1
  68. package/coverage/lcov-report/dist/test-utils/thirteen/models/category.js.html +1 -1
  69. package/coverage/lcov-report/dist/test-utils/thirteen/models/index.html +1 -1
  70. package/coverage/lcov-report/dist/test-utils/thirteen/models/member.js.html +1 -1
  71. package/coverage/lcov-report/dist/test-utils/thirteen/models/passion.js.html +1 -1
  72. package/coverage/lcov-report/dist/test-utils/thirteen/models/product.js.html +1 -1
  73. package/coverage/lcov-report/dist/test-utils/thirteen/models/recommendation-audience.js.html +1 -1
  74. package/coverage/lcov-report/dist/test-utils/thirteen/models/recommendation.js.html +1 -1
  75. package/coverage/lcov-report/dist/test-utils/thirteen/orm.js.html +1 -1
  76. package/coverage/lcov-report/dist/test-utils/three/index.html +1 -1
  77. package/coverage/lcov-report/dist/test-utils/three/results.js.html +1 -1
  78. package/coverage/lcov-report/dist/test-utils/twelve/index.html +1 -1
  79. package/coverage/lcov-report/dist/test-utils/twelve/models/index.html +1 -1
  80. package/coverage/lcov-report/dist/test-utils/twelve/models/member.js.html +1 -1
  81. package/coverage/lcov-report/dist/test-utils/twelve/models/prompt.js.html +1 -1
  82. package/coverage/lcov-report/dist/test-utils/twelve/orm.js.html +1 -1
  83. package/coverage/lcov-report/dist/test-utils/two/index.html +1 -1
  84. package/coverage/lcov-report/dist/test-utils/two/results.js.html +1 -1
  85. package/coverage/lcov-report/index.html +1 -1
  86. package/coverage/lcov-report/src/factory.ts.html +25 -10
  87. package/coverage/lcov-report/src/index.html +1 -1
  88. package/coverage/lcov-report/src/index.ts.html +1 -1
  89. package/coverage/lcov-report/test-utils/blog/index.html +1 -1
  90. package/coverage/lcov-report/test-utils/blog/models/article.ts.html +1 -1
  91. package/coverage/lcov-report/test-utils/blog/models/article_tag.ts.html +1 -1
  92. package/coverage/lcov-report/test-utils/blog/models/index.html +1 -1
  93. package/coverage/lcov-report/test-utils/blog/models/person.ts.html +1 -1
  94. package/coverage/lcov-report/test-utils/blog/models/tag.ts.html +1 -1
  95. package/coverage/lcov-report/test-utils/blog/orm.ts.html +1 -1
  96. package/coverage/lcov-report/test-utils/five/index.html +1 -1
  97. package/coverage/lcov-report/test-utils/five/models/index.html +1 -1
  98. package/coverage/lcov-report/test-utils/five/models/line-item.ts.html +1 -1
  99. package/coverage/lcov-report/test-utils/five/models/order.ts.html +1 -1
  100. package/coverage/lcov-report/test-utils/five/models/parcel-event.ts.html +1 -1
  101. package/coverage/lcov-report/test-utils/five/models/parcel-line-item.ts.html +1 -1
  102. package/coverage/lcov-report/test-utils/five/models/parcel.ts.html +1 -1
  103. package/coverage/lcov-report/test-utils/five/orm.ts.html +1 -1
  104. package/coverage/lcov-report/test-utils/nine/index.html +1 -1
  105. package/coverage/lcov-report/test-utils/nine/models/feature-switch.ts.html +1 -1
  106. package/coverage/lcov-report/test-utils/nine/models/index.html +1 -1
  107. package/coverage/lcov-report/test-utils/nine/orm.ts.html +1 -1
  108. package/coverage/lcov-report/test-utils/order/index.html +1 -1
  109. package/coverage/lcov-report/test-utils/order/models/index.html +1 -1
  110. package/coverage/lcov-report/test-utils/order/models/line-item.ts.html +1 -1
  111. package/coverage/lcov-report/test-utils/order/models/order.ts.html +1 -1
  112. package/coverage/lcov-report/test-utils/order/models/product-variant.ts.html +1 -1
  113. package/coverage/lcov-report/test-utils/order/models/product.ts.html +1 -1
  114. package/coverage/lcov-report/test-utils/order/models/utm-source.ts.html +1 -1
  115. package/coverage/lcov-report/test-utils/order/orm.ts.html +1 -1
  116. package/coverage/lcov-report/test-utils/order-more/index.html +1 -1
  117. package/coverage/lcov-report/test-utils/order-more/models/actual-product-variant.ts.html +1 -1
  118. package/coverage/lcov-report/test-utils/order-more/models/color.ts.html +1 -1
  119. package/coverage/lcov-report/test-utils/order-more/models/customer.ts.html +1 -1
  120. package/coverage/lcov-report/test-utils/order-more/models/gender.ts.html +1 -1
  121. package/coverage/lcov-report/test-utils/order-more/models/index.html +1 -1
  122. package/coverage/lcov-report/test-utils/order-more/models/inventory-level.ts.html +1 -1
  123. package/coverage/lcov-report/test-utils/order-more/models/line-item.ts.html +1 -1
  124. package/coverage/lcov-report/test-utils/order-more/models/order.ts.html +1 -1
  125. package/coverage/lcov-report/test-utils/order-more/models/parcel-event.ts.html +1 -1
  126. package/coverage/lcov-report/test-utils/order-more/models/parcel-line-item.ts.html +1 -1
  127. package/coverage/lcov-report/test-utils/order-more/models/parcel.ts.html +1 -1
  128. package/coverage/lcov-report/test-utils/order-more/models/physical-address.ts.html +1 -1
  129. package/coverage/lcov-report/test-utils/order-more/models/product-variant-image.ts.html +1 -1
  130. package/coverage/lcov-report/test-utils/order-more/models/product-variant.ts.html +1 -1
  131. package/coverage/lcov-report/test-utils/order-more/models/product.ts.html +1 -1
  132. package/coverage/lcov-report/test-utils/order-more/models/refund.ts.html +1 -1
  133. package/coverage/lcov-report/test-utils/order-more/models/shipment-actual-product-variant.ts.html +1 -1
  134. package/coverage/lcov-report/test-utils/order-more/models/shipment.ts.html +1 -1
  135. package/coverage/lcov-report/test-utils/order-more/models/size.ts.html +1 -1
  136. package/coverage/lcov-report/test-utils/order-more/models/utm-medium.ts.html +1 -1
  137. package/coverage/lcov-report/test-utils/order-more/models/utm-source.ts.html +1 -1
  138. package/coverage/lcov-report/test-utils/order-more/orm.ts.html +1 -1
  139. package/coverage/lcov-report/test-utils/six/index.html +1 -1
  140. package/coverage/lcov-report/test-utils/six/models/customer.ts.html +1 -1
  141. package/coverage/lcov-report/test-utils/six/models/index.html +1 -1
  142. package/coverage/lcov-report/test-utils/six/models/line-item.ts.html +1 -1
  143. package/coverage/lcov-report/test-utils/six/models/order.ts.html +1 -1
  144. package/coverage/lcov-report/test-utils/six/models/parcel-line-item.ts.html +1 -1
  145. package/coverage/lcov-report/test-utils/six/models/parcel.ts.html +1 -1
  146. package/coverage/lcov-report/test-utils/six/orm.ts.html +1 -1
  147. package/coverage/lcov-report/test-utils/thirteen/index.html +1 -1
  148. package/coverage/lcov-report/test-utils/thirteen/models/audience.ts.html +1 -1
  149. package/coverage/lcov-report/test-utils/thirteen/models/brand.ts.html +1 -1
  150. package/coverage/lcov-report/test-utils/thirteen/models/category.ts.html +1 -1
  151. package/coverage/lcov-report/test-utils/thirteen/models/index.html +1 -1
  152. package/coverage/lcov-report/test-utils/thirteen/models/member.ts.html +1 -1
  153. package/coverage/lcov-report/test-utils/thirteen/models/passion.ts.html +1 -1
  154. package/coverage/lcov-report/test-utils/thirteen/models/product.ts.html +1 -1
  155. package/coverage/lcov-report/test-utils/thirteen/models/recommendation-audience.ts.html +1 -1
  156. package/coverage/lcov-report/test-utils/thirteen/models/recommendation.ts.html +1 -1
  157. package/coverage/lcov-report/test-utils/thirteen/orm.ts.html +1 -1
  158. package/coverage/lcov-report/test-utils/three/index.html +1 -1
  159. package/coverage/lcov-report/test-utils/three/results.js.html +1 -1
  160. package/coverage/lcov-report/test-utils/twelve/index.html +1 -1
  161. package/coverage/lcov-report/test-utils/twelve/models/index.html +1 -1
  162. package/coverage/lcov-report/test-utils/twelve/models/member.ts.html +1 -1
  163. package/coverage/lcov-report/test-utils/twelve/models/prompt.ts.html +1 -1
  164. package/coverage/lcov-report/test-utils/twelve/orm.ts.html +1 -1
  165. package/coverage/lcov-report/test-utils/two/index.html +1 -1
  166. package/coverage/lcov-report/test-utils/two/results.js.html +1 -1
  167. package/coverage/lcov.info +5 -5
  168. package/dist/example/factories/orm.d.ts +2 -1
  169. package/dist/src/factory.d.ts +3 -2
  170. package/dist/src/factory.js +7 -2
  171. package/dist/src/factory.spec.js +5 -5
  172. package/dist/test-utils/five/orm.d.ts +2 -1
  173. package/dist/test-utils/nine/orm.d.ts +2 -1
  174. package/dist/test-utils/order/orm.d.ts +2 -1
  175. package/dist/test-utils/order-more/orm.d.ts +2 -1
  176. package/dist/test-utils/six/orm.d.ts +2 -1
  177. package/dist/test-utils/thirteen/orm.d.ts +2 -1
  178. package/dist/test-utils/twelve/orm.d.ts +2 -1
  179. package/package.json +1 -1
  180. package/src/factory.spec.ts +5 -5
  181. package/src/factory.ts +13 -8
@@ -93,7 +93,7 @@
93
93
  </div><!-- /wrapper -->
94
94
  <div class='footer quiet pad2 space-top1 center small'>
95
95
  Code coverage
96
- generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 09:59:45 GMT-0400 (Eastern Daylight Time)
96
+ generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 11:10:01 GMT-0400 (Eastern Daylight Time)
97
97
  </div>
98
98
  </div>
99
99
  <script src="../../../prettify.js"></script>
@@ -133,7 +133,7 @@ export const memberEntity = {
133
133
  </div><!-- /wrapper -->
134
134
  <div class='footer quiet pad2 space-top1 center small'>
135
135
  Code coverage
136
- generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 09:59:45 GMT-0400 (Eastern Daylight Time)
136
+ generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 11:10:01 GMT-0400 (Eastern Daylight Time)
137
137
  </div>
138
138
  </div>
139
139
  <script src="../../../prettify.js"></script>
@@ -172,7 +172,7 @@ export const promptEntity = {
172
172
  </div><!-- /wrapper -->
173
173
  <div class='footer quiet pad2 space-top1 center small'>
174
174
  Code coverage
175
- generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 09:59:45 GMT-0400 (Eastern Daylight Time)
175
+ generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 11:10:01 GMT-0400 (Eastern Daylight Time)
176
176
  </div>
177
177
  </div>
178
178
  <script src="../../../prettify.js"></script>
@@ -76,7 +76,7 @@ export default orm;
76
76
  </div><!-- /wrapper -->
77
77
  <div class='footer quiet pad2 space-top1 center small'>
78
78
  Code coverage
79
- generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 09:59:45 GMT-0400 (Eastern Daylight Time)
79
+ generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 11:10:01 GMT-0400 (Eastern Daylight Time)
80
80
  </div>
81
81
  </div>
82
82
  <script src="../../prettify.js"></script>
@@ -80,7 +80,7 @@
80
80
  </div><!-- /wrapper -->
81
81
  <div class='footer quiet pad2 space-top1 center small'>
82
82
  Code coverage
83
- generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 09:59:45 GMT-0400 (Eastern Daylight Time)
83
+ generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 11:10:01 GMT-0400 (Eastern Daylight Time)
84
84
  </div>
85
85
  </div>
86
86
  <script src="../../prettify.js"></script>
@@ -1018,7 +1018,7 @@
1018
1018
  </div><!-- /wrapper -->
1019
1019
  <div class='footer quiet pad2 space-top1 center small'>
1020
1020
  Code coverage
1021
- generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 09:59:45 GMT-0400 (Eastern Daylight Time)
1021
+ generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Thu May 05 2022 11:10:01 GMT-0400 (Eastern Daylight Time)
1022
1022
  </div>
1023
1023
  </div>
1024
1024
  <script src="../../prettify.js"></script>
@@ -92,7 +92,7 @@ FN:439,(anonymous_88)
92
92
  FN:448,(anonymous_89)
93
93
  FN:457,(anonymous_90)
94
94
  FN:466,(anonymous_91)
95
- FN:506,(anonymous_92)
95
+ FN:507,(anonymous_92)
96
96
  FNF:93
97
97
  FNH:43
98
98
  FNDA:8,(anonymous_0)
@@ -446,9 +446,9 @@ DA:467,0
446
446
  DA:468,0
447
447
  DA:473,0
448
448
  DA:475,8
449
- DA:507,50
450
449
  DA:508,50
451
- DA:512,1
450
+ DA:511,50
451
+ DA:517,1
452
452
  LF:261
453
453
  LH:162
454
454
  BRDA:8,0,0,50
@@ -2272,7 +2272,7 @@ FN:661,(anonymous_88)
2272
2272
  FN:671,(anonymous_89)
2273
2273
  FN:681,(anonymous_90)
2274
2274
  FN:693,(anonymous_91)
2275
- FN:734,(anonymous_92)
2275
+ FN:735,(anonymous_92)
2276
2276
  FNF:93
2277
2277
  FNH:43
2278
2278
  FNDA:8,(anonymous_0)
@@ -2632,8 +2632,8 @@ DA:694,0
2632
2632
  DA:695,0
2633
2633
  DA:700,0
2634
2634
  DA:703,8
2635
- DA:735,50
2636
2635
  DA:736,50
2636
+ DA:739,50
2637
2637
  LF:266
2638
2638
  LH:165
2639
2639
  BRDA:71,0,0,50
@@ -1,7 +1,7 @@
1
1
  declare const orm: {
2
2
  nestClump: (clump: import("../../src/factory").IModel[][]) => object;
3
3
  clumpIntoGroups: (processed: import("../../src/factory").IModel[][]) => import("../../src/factory").IModel[][][];
4
- mapToBos: (objectified: any) => any[];
4
+ mapToBos: (objectified: any) => import("../../src/factory").IModel[];
5
5
  objectifyDatabaseResult: (result: object) => any;
6
6
  createFromDatabase: <T extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(_result: object | object[]) => T | undefined;
7
7
  createOneFromDatabase: <T_1 extends import("../../src/factory").IModel>(_result: any) => T_1;
@@ -43,5 +43,6 @@ declare const orm: {
43
43
  getAnyMatching: <T_14 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => void | T_14;
44
44
  getAllMatching: <T_15 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => T_15;
45
45
  tables: any;
46
+ db: any;
46
47
  };
47
48
  export default orm;
@@ -47,14 +47,14 @@ export interface IEntityInternal<T extends IModel> {
47
47
  }
48
48
  export declare type IEntitiesInternal<T extends IModel> = Array<IEntityInternal<T>>;
49
49
  export interface CreateOptions {
50
- entities: IEntities<any>;
50
+ entities: IEntities<IModel>;
51
51
  db: any;
52
52
  logError?: (err: Error) => void;
53
53
  }
54
54
  export declare const create: ({ entities: externalEntities, db, logError }: CreateOptions) => {
55
55
  nestClump: (clump: Array<Array<IModel>>) => object;
56
56
  clumpIntoGroups: (processed: Array<Array<IModel>>) => Array<Array<Array<IModel>>>;
57
- mapToBos: (objectified: any) => any[];
57
+ mapToBos: (objectified: any) => IModel[];
58
58
  objectifyDatabaseResult: (result: object) => any;
59
59
  createFromDatabase: <T extends ICollection<IModel>>(_result: Array<object> | object) => T | undefined;
60
60
  createOneFromDatabase: <T_1 extends IModel>(_result: any) => T_1;
@@ -96,4 +96,5 @@ export declare const create: ({ entities: externalEntities, db, logError }: Crea
96
96
  getAnyMatching: <T_14 extends ICollection<IModel>>(model: IModel) => void | T_14;
97
97
  getAllMatching: <T_15 extends ICollection<IModel>>(model: IModel) => T_15;
98
98
  tables: any;
99
+ db: any;
99
100
  };
@@ -503,10 +503,15 @@ const create = ({ entities: externalEntities, db, logError }) => {
503
503
  getOneOrNoneMatching,
504
504
  getAnyMatching,
505
505
  getAllMatching,
506
+ // tables property for access to select columns clause string
506
507
  tables: entities.reduce((accum, data) => {
507
- accum[data.displayName] = data.selectColumnsClause;
508
+ accum[data.displayName] = {
509
+ columns: data.selectColumnsClause
510
+ };
508
511
  return accum;
509
- }, {})
512
+ }, {}),
513
+ // provide direct access to db
514
+ db
510
515
  };
511
516
  };
512
517
  exports.create = create;
@@ -558,9 +558,9 @@ test('Bo#parseFromDatabase 13', () => {
558
558
  });
559
559
  test('orm.tables', () => {
560
560
  expect(Object.keys(orm_1.default.tables).length).toEqual(5);
561
- expect(orm_1.default.tables.utmSource).toEqual('"utm_source".id as "utm_source#id", "utm_source".value as "utm_source#value", "utm_source".label as "utm_source#label", "utm_source".internal as "utm_source#internal"');
562
- expect(orm_1.default.tables.order).toEqual('"order".id as "order#id", "order".email as "order#email", "order".browser_ip as "order#browser_ip", "order".browser_user_agent as "order#browser_user_agent", "order".kujo_imported_date as "order#kujo_imported_date", "order".created_date as "order#created_date", "order".cancel_reason as "order#cancel_reason", "order".cancelled_date as "order#cancelled_date", "order".closed_date as "order#closed_date", "order".processed_date as "order#processed_date", "order".updated_date as "order#updated_date", "order".note as "order#note", "order".subtotal_price as "order#subtotal_price", "order".taxes_included as "order#taxes_included", "order".total_discounts as "order#total_discounts", "order".total_price as "order#total_price", "order".total_tax as "order#total_tax", "order".total_weight as "order#total_weight", "order".order_status_url as "order#order_status_url", "order".utm_source_id as "order#utm_source_id", "order".utm_medium_id as "order#utm_medium_id", "order".utm_campaign as "order#utm_campaign", "order".utm_content as "order#utm_content", "order".utm_term as "order#utm_term"');
563
- expect(orm_1.default.tables.lineItem).toEqual('"line_item".id as "line_item#id", "line_item".product_variant_id as "line_item#product_variant_id", "line_item".order_id as "line_item#order_id", "line_item".fulfillment_status_id as "line_item#fulfillment_status_id", "line_item".fulfillable_quantity as "line_item#fulfillable_quantity", "line_item".fulfillment_service as "line_item#fulfillment_service", "line_item".grams as "line_item#grams", "line_item".price as "line_item#price", "line_item".quantity as "line_item#quantity", "line_item".requires_shipping as "line_item#requires_shipping", "line_item".taxable as "line_item#taxable", "line_item".total_discount as "line_item#total_discount"');
564
- expect(orm_1.default.tables.productVariant).toEqual('"product_variant".id as "product_variant#id", "product_variant".product_id as "product_variant#product_id", "product_variant".actual_product_variant_id as "product_variant#actual_product_variant_id", "product_variant".color_id as "product_variant#color_id", "product_variant".gender_id as "product_variant#gender_id", "product_variant".size_id as "product_variant#size_id", "product_variant".barcode as "product_variant#barcode", "product_variant".price as "product_variant#price", "product_variant".compare_at_price as "product_variant#compare_at_price", "product_variant".created_date as "product_variant#created_date", "product_variant".updated_date as "product_variant#updated_date", "product_variant".grams as "product_variant#grams", "product_variant".requires_shipping as "product_variant#requires_shipping"');
565
- expect(orm_1.default.tables.product).toEqual('"product".id as "product#id", "product".vendor_id as "product#vendor_id", "product".value as "product#value", "product".label as "product#label", "product".product_type as "product#product_type", "product".created_date as "product#created_date", "product".updated_date as "product#updated_date", "product".published_date as "product#published_date", "product".category as "product#category"');
561
+ expect(orm_1.default.tables.utmSource.columns).toEqual('"utm_source".id as "utm_source#id", "utm_source".value as "utm_source#value", "utm_source".label as "utm_source#label", "utm_source".internal as "utm_source#internal"');
562
+ expect(orm_1.default.tables.order.columns).toEqual('"order".id as "order#id", "order".email as "order#email", "order".browser_ip as "order#browser_ip", "order".browser_user_agent as "order#browser_user_agent", "order".kujo_imported_date as "order#kujo_imported_date", "order".created_date as "order#created_date", "order".cancel_reason as "order#cancel_reason", "order".cancelled_date as "order#cancelled_date", "order".closed_date as "order#closed_date", "order".processed_date as "order#processed_date", "order".updated_date as "order#updated_date", "order".note as "order#note", "order".subtotal_price as "order#subtotal_price", "order".taxes_included as "order#taxes_included", "order".total_discounts as "order#total_discounts", "order".total_price as "order#total_price", "order".total_tax as "order#total_tax", "order".total_weight as "order#total_weight", "order".order_status_url as "order#order_status_url", "order".utm_source_id as "order#utm_source_id", "order".utm_medium_id as "order#utm_medium_id", "order".utm_campaign as "order#utm_campaign", "order".utm_content as "order#utm_content", "order".utm_term as "order#utm_term"');
563
+ expect(orm_1.default.tables.lineItem.columns).toEqual('"line_item".id as "line_item#id", "line_item".product_variant_id as "line_item#product_variant_id", "line_item".order_id as "line_item#order_id", "line_item".fulfillment_status_id as "line_item#fulfillment_status_id", "line_item".fulfillable_quantity as "line_item#fulfillable_quantity", "line_item".fulfillment_service as "line_item#fulfillment_service", "line_item".grams as "line_item#grams", "line_item".price as "line_item#price", "line_item".quantity as "line_item#quantity", "line_item".requires_shipping as "line_item#requires_shipping", "line_item".taxable as "line_item#taxable", "line_item".total_discount as "line_item#total_discount"');
564
+ expect(orm_1.default.tables.productVariant.columns).toEqual('"product_variant".id as "product_variant#id", "product_variant".product_id as "product_variant#product_id", "product_variant".actual_product_variant_id as "product_variant#actual_product_variant_id", "product_variant".color_id as "product_variant#color_id", "product_variant".gender_id as "product_variant#gender_id", "product_variant".size_id as "product_variant#size_id", "product_variant".barcode as "product_variant#barcode", "product_variant".price as "product_variant#price", "product_variant".compare_at_price as "product_variant#compare_at_price", "product_variant".created_date as "product_variant#created_date", "product_variant".updated_date as "product_variant#updated_date", "product_variant".grams as "product_variant#grams", "product_variant".requires_shipping as "product_variant#requires_shipping"');
565
+ expect(orm_1.default.tables.product.columns).toEqual('"product".id as "product#id", "product".vendor_id as "product#vendor_id", "product".value as "product#value", "product".label as "product#label", "product".product_type as "product#product_type", "product".created_date as "product#created_date", "product".updated_date as "product#updated_date", "product".published_date as "product#published_date", "product".category as "product#category"');
566
566
  });
@@ -1,7 +1,7 @@
1
1
  declare const orm: {
2
2
  nestClump: (clump: import("../../src/factory").IModel[][]) => object;
3
3
  clumpIntoGroups: (processed: import("../../src/factory").IModel[][]) => import("../../src/factory").IModel[][][];
4
- mapToBos: (objectified: any) => any[];
4
+ mapToBos: (objectified: any) => import("../../src/factory").IModel[];
5
5
  objectifyDatabaseResult: (result: object) => any;
6
6
  createFromDatabase: <T extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(_result: object | object[]) => T | undefined;
7
7
  createOneFromDatabase: <T_1 extends import("../../src/factory").IModel>(_result: any) => T_1;
@@ -43,5 +43,6 @@ declare const orm: {
43
43
  getAnyMatching: <T_14 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => void | T_14;
44
44
  getAllMatching: <T_15 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => T_15;
45
45
  tables: any;
46
+ db: any;
46
47
  };
47
48
  export default orm;
@@ -1,7 +1,7 @@
1
1
  declare const orm: {
2
2
  nestClump: (clump: import("../../src/factory").IModel[][]) => object;
3
3
  clumpIntoGroups: (processed: import("../../src/factory").IModel[][]) => import("../../src/factory").IModel[][][];
4
- mapToBos: (objectified: any) => any[];
4
+ mapToBos: (objectified: any) => import("../../src/factory").IModel[];
5
5
  objectifyDatabaseResult: (result: object) => any;
6
6
  createFromDatabase: <T extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(_result: object | object[]) => T | undefined;
7
7
  createOneFromDatabase: <T_1 extends import("../../src/factory").IModel>(_result: any) => T_1;
@@ -43,5 +43,6 @@ declare const orm: {
43
43
  getAnyMatching: <T_14 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => void | T_14;
44
44
  getAllMatching: <T_15 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => T_15;
45
45
  tables: any;
46
+ db: any;
46
47
  };
47
48
  export default orm;
@@ -1,7 +1,7 @@
1
1
  declare const orm: {
2
2
  nestClump: (clump: import("../../src/factory").IModel[][]) => object;
3
3
  clumpIntoGroups: (processed: import("../../src/factory").IModel[][]) => import("../../src/factory").IModel[][][];
4
- mapToBos: (objectified: any) => any[];
4
+ mapToBos: (objectified: any) => import("../../src/factory").IModel[];
5
5
  objectifyDatabaseResult: (result: object) => any;
6
6
  createFromDatabase: <T extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(_result: object | object[]) => T | undefined;
7
7
  createOneFromDatabase: <T_1 extends import("../../src/factory").IModel>(_result: any) => T_1;
@@ -43,5 +43,6 @@ declare const orm: {
43
43
  getAnyMatching: <T_14 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => void | T_14;
44
44
  getAllMatching: <T_15 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => T_15;
45
45
  tables: any;
46
+ db: any;
46
47
  };
47
48
  export default orm;
@@ -1,7 +1,7 @@
1
1
  declare const orm: {
2
2
  nestClump: (clump: import("../../src/factory").IModel[][]) => object;
3
3
  clumpIntoGroups: (processed: import("../../src/factory").IModel[][]) => import("../../src/factory").IModel[][][];
4
- mapToBos: (objectified: any) => any[];
4
+ mapToBos: (objectified: any) => import("../../src/factory").IModel[];
5
5
  objectifyDatabaseResult: (result: object) => any;
6
6
  createFromDatabase: <T extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(_result: object | object[]) => T | undefined;
7
7
  createOneFromDatabase: <T_1 extends import("../../src/factory").IModel>(_result: any) => T_1;
@@ -43,5 +43,6 @@ declare const orm: {
43
43
  getAnyMatching: <T_14 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => void | T_14;
44
44
  getAllMatching: <T_15 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => T_15;
45
45
  tables: any;
46
+ db: any;
46
47
  };
47
48
  export default orm;
@@ -1,7 +1,7 @@
1
1
  declare const orm: {
2
2
  nestClump: (clump: import("../../src/factory").IModel[][]) => object;
3
3
  clumpIntoGroups: (processed: import("../../src/factory").IModel[][]) => import("../../src/factory").IModel[][][];
4
- mapToBos: (objectified: any) => any[];
4
+ mapToBos: (objectified: any) => import("../../src/factory").IModel[];
5
5
  objectifyDatabaseResult: (result: object) => any;
6
6
  createFromDatabase: <T extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(_result: object | object[]) => T | undefined;
7
7
  createOneFromDatabase: <T_1 extends import("../../src/factory").IModel>(_result: any) => T_1;
@@ -43,5 +43,6 @@ declare const orm: {
43
43
  getAnyMatching: <T_14 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => void | T_14;
44
44
  getAllMatching: <T_15 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => T_15;
45
45
  tables: any;
46
+ db: any;
46
47
  };
47
48
  export default orm;
@@ -1,7 +1,7 @@
1
1
  declare const orm: {
2
2
  nestClump: (clump: import("../../src/factory").IModel[][]) => object;
3
3
  clumpIntoGroups: (processed: import("../../src/factory").IModel[][]) => import("../../src/factory").IModel[][][];
4
- mapToBos: (objectified: any) => any[];
4
+ mapToBos: (objectified: any) => import("../../src/factory").IModel[];
5
5
  objectifyDatabaseResult: (result: object) => any;
6
6
  createFromDatabase: <T extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(_result: object | object[]) => T | undefined;
7
7
  createOneFromDatabase: <T_1 extends import("../../src/factory").IModel>(_result: any) => T_1;
@@ -43,5 +43,6 @@ declare const orm: {
43
43
  getAnyMatching: <T_14 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => void | T_14;
44
44
  getAllMatching: <T_15 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => T_15;
45
45
  tables: any;
46
+ db: any;
46
47
  };
47
48
  export default orm;
@@ -1,7 +1,7 @@
1
1
  declare const orm: {
2
2
  nestClump: (clump: import("../../src/factory").IModel[][]) => object;
3
3
  clumpIntoGroups: (processed: import("../../src/factory").IModel[][]) => import("../../src/factory").IModel[][][];
4
- mapToBos: (objectified: any) => any[];
4
+ mapToBos: (objectified: any) => import("../../src/factory").IModel[];
5
5
  objectifyDatabaseResult: (result: object) => any;
6
6
  createFromDatabase: <T extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(_result: object | object[]) => T | undefined;
7
7
  createOneFromDatabase: <T_1 extends import("../../src/factory").IModel>(_result: any) => T_1;
@@ -43,5 +43,6 @@ declare const orm: {
43
43
  getAnyMatching: <T_14 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => void | T_14;
44
44
  getAllMatching: <T_15 extends import("../../src/factory").ICollection<import("../../src/factory").IModel>>(model: import("../../src/factory").IModel) => T_15;
45
45
  tables: any;
46
+ db: any;
46
47
  };
47
48
  export default orm;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pure-orm",
3
- "version": "4.0.0-4",
3
+ "version": "4.0.0-5",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "engines": {
@@ -1030,19 +1030,19 @@ test('Bo#parseFromDatabase 13', () => {
1030
1030
 
1031
1031
  test('orm.tables', () => {
1032
1032
  expect(Object.keys(ormA.tables).length).toEqual(5);
1033
- expect(ormA.tables.utmSource).toEqual(
1033
+ expect(ormA.tables.utmSource.columns).toEqual(
1034
1034
  '"utm_source".id as "utm_source#id", "utm_source".value as "utm_source#value", "utm_source".label as "utm_source#label", "utm_source".internal as "utm_source#internal"'
1035
1035
  );
1036
- expect(ormA.tables.order).toEqual(
1036
+ expect(ormA.tables.order.columns).toEqual(
1037
1037
  '"order".id as "order#id", "order".email as "order#email", "order".browser_ip as "order#browser_ip", "order".browser_user_agent as "order#browser_user_agent", "order".kujo_imported_date as "order#kujo_imported_date", "order".created_date as "order#created_date", "order".cancel_reason as "order#cancel_reason", "order".cancelled_date as "order#cancelled_date", "order".closed_date as "order#closed_date", "order".processed_date as "order#processed_date", "order".updated_date as "order#updated_date", "order".note as "order#note", "order".subtotal_price as "order#subtotal_price", "order".taxes_included as "order#taxes_included", "order".total_discounts as "order#total_discounts", "order".total_price as "order#total_price", "order".total_tax as "order#total_tax", "order".total_weight as "order#total_weight", "order".order_status_url as "order#order_status_url", "order".utm_source_id as "order#utm_source_id", "order".utm_medium_id as "order#utm_medium_id", "order".utm_campaign as "order#utm_campaign", "order".utm_content as "order#utm_content", "order".utm_term as "order#utm_term"'
1038
1038
  );
1039
- expect(ormA.tables.lineItem).toEqual(
1039
+ expect(ormA.tables.lineItem.columns).toEqual(
1040
1040
  '"line_item".id as "line_item#id", "line_item".product_variant_id as "line_item#product_variant_id", "line_item".order_id as "line_item#order_id", "line_item".fulfillment_status_id as "line_item#fulfillment_status_id", "line_item".fulfillable_quantity as "line_item#fulfillable_quantity", "line_item".fulfillment_service as "line_item#fulfillment_service", "line_item".grams as "line_item#grams", "line_item".price as "line_item#price", "line_item".quantity as "line_item#quantity", "line_item".requires_shipping as "line_item#requires_shipping", "line_item".taxable as "line_item#taxable", "line_item".total_discount as "line_item#total_discount"'
1041
1041
  );
1042
- expect(ormA.tables.productVariant).toEqual(
1042
+ expect(ormA.tables.productVariant.columns).toEqual(
1043
1043
  '"product_variant".id as "product_variant#id", "product_variant".product_id as "product_variant#product_id", "product_variant".actual_product_variant_id as "product_variant#actual_product_variant_id", "product_variant".color_id as "product_variant#color_id", "product_variant".gender_id as "product_variant#gender_id", "product_variant".size_id as "product_variant#size_id", "product_variant".barcode as "product_variant#barcode", "product_variant".price as "product_variant#price", "product_variant".compare_at_price as "product_variant#compare_at_price", "product_variant".created_date as "product_variant#created_date", "product_variant".updated_date as "product_variant#updated_date", "product_variant".grams as "product_variant#grams", "product_variant".requires_shipping as "product_variant#requires_shipping"'
1044
1044
  );
1045
- expect(ormA.tables.product).toEqual(
1045
+ expect(ormA.tables.product.columns).toEqual(
1046
1046
  '"product".id as "product#id", "product".vendor_id as "product#vendor_id", "product".value as "product#value", "product".label as "product#label", "product".product_type as "product#product_type", "product".created_date as "product#created_date", "product".updated_date as "product#updated_date", "product".published_date as "product#published_date", "product".category as "product#category"'
1047
1047
  );
1048
1048
  });
package/src/factory.ts CHANGED
@@ -55,7 +55,7 @@ export interface IEntityInternal<T extends IModel> {
55
55
  export type IEntitiesInternal<T extends IModel> = Array<IEntityInternal<T>>;
56
56
 
57
57
  export interface CreateOptions {
58
- entities: IEntities<any>;
58
+ entities: IEntities<IModel>;
59
59
  db: any;
60
60
  logError?: (err: Error) => void;
61
61
  }
@@ -65,8 +65,8 @@ export const create = ({
65
65
  db,
66
66
  logError
67
67
  }: CreateOptions) => {
68
- const entities: IEntitiesInternal<any> = externalEntities.map(
69
- (d: IEntity<any>) => {
68
+ const entities: IEntitiesInternal<IModel> = externalEntities.map(
69
+ (d: IEntity<IModel>) => {
70
70
  const tableName = d.tableName;
71
71
  const displayName = d.displayName || camelCase(d.tableName);
72
72
  const collectionDisplayName =
@@ -146,7 +146,7 @@ export const create = ({
146
146
  }
147
147
  );
148
148
 
149
- const getEntityByTableName = (tableName: string): IEntityInternal<any> => {
149
+ const getEntityByTableName = (tableName: string): IEntityInternal<IModel> => {
150
150
  const entity = entities.find((data) => data.tableName == tableName);
151
151
  if (!entity) {
152
152
  throw new Error(`Could not find entity for table ${tableName}`);
@@ -154,7 +154,7 @@ export const create = ({
154
154
  return entity;
155
155
  };
156
156
 
157
- const getEntityByModel = (model: IModel): IEntityInternal<any> => {
157
+ const getEntityByModel = (model: IModel): IEntityInternal<IModel> => {
158
158
  const entity = entities.find((data) => data.Model == model.constructor);
159
159
  if (!entity) {
160
160
  throw new Error(`Could not find entity for class ${model.constructor}`);
@@ -731,9 +731,14 @@ export const create = ({
731
731
  getOneOrNoneMatching,
732
732
  getAnyMatching,
733
733
  getAllMatching,
734
- tables: entities.reduce((accum: any, data: IEntityInternal<any>) => {
735
- accum[data.displayName] = data.selectColumnsClause;
734
+ // tables property for access to select columns clause string
735
+ tables: entities.reduce((accum: any, data: IEntityInternal<IModel>) => {
736
+ accum[data.displayName] = {
737
+ columns: data.selectColumnsClause
738
+ };
736
739
  return accum;
737
- }, {})
740
+ }, {}),
741
+ // provide direct access to db
742
+ db
738
743
  };
739
744
  };