@orchestr-sh/orchestr 1.2.1 → 1.4.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 (42) hide show
  1. package/README.md +176 -34
  2. package/dist/Database/Ensemble/Concerns/HasRelationships.d.ts +96 -0
  3. package/dist/Database/Ensemble/Concerns/HasRelationships.d.ts.map +1 -0
  4. package/dist/Database/Ensemble/Concerns/HasRelationships.js +145 -0
  5. package/dist/Database/Ensemble/Concerns/HasRelationships.js.map +1 -0
  6. package/dist/Database/Ensemble/Ensemble.d.ts +18 -1
  7. package/dist/Database/Ensemble/Ensemble.d.ts.map +1 -1
  8. package/dist/Database/Ensemble/Ensemble.js +45 -1
  9. package/dist/Database/Ensemble/Ensemble.js.map +1 -1
  10. package/dist/Database/Ensemble/EnsembleBuilder.d.ts +19 -2
  11. package/dist/Database/Ensemble/EnsembleBuilder.d.ts.map +1 -1
  12. package/dist/Database/Ensemble/EnsembleBuilder.js +105 -4
  13. package/dist/Database/Ensemble/EnsembleBuilder.js.map +1 -1
  14. package/dist/Database/Ensemble/Relations/BelongsTo.d.ts +92 -0
  15. package/dist/Database/Ensemble/Relations/BelongsTo.d.ts.map +1 -0
  16. package/dist/Database/Ensemble/Relations/BelongsTo.js +174 -0
  17. package/dist/Database/Ensemble/Relations/BelongsTo.js.map +1 -0
  18. package/dist/Database/Ensemble/Relations/HasMany.d.ts +100 -0
  19. package/dist/Database/Ensemble/Relations/HasMany.d.ts.map +1 -0
  20. package/dist/Database/Ensemble/Relations/HasMany.js +199 -0
  21. package/dist/Database/Ensemble/Relations/HasMany.js.map +1 -0
  22. package/dist/Database/Ensemble/Relations/HasOne.d.ts +76 -0
  23. package/dist/Database/Ensemble/Relations/HasOne.d.ts.map +1 -0
  24. package/dist/Database/Ensemble/Relations/HasOne.js +142 -0
  25. package/dist/Database/Ensemble/Relations/HasOne.js.map +1 -0
  26. package/dist/Database/Ensemble/Relations/Relation.d.ts +114 -0
  27. package/dist/Database/Ensemble/Relations/Relation.d.ts.map +1 -0
  28. package/dist/Database/Ensemble/Relations/Relation.js +137 -0
  29. package/dist/Database/Ensemble/Relations/Relation.js.map +1 -0
  30. package/dist/Database/Ensemble/Relations/index.d.ts +10 -0
  31. package/dist/Database/Ensemble/Relations/index.d.ts.map +1 -0
  32. package/dist/Database/Ensemble/Relations/index.js +17 -0
  33. package/dist/Database/Ensemble/Relations/index.js.map +1 -0
  34. package/dist/Support/Injectable.d.ts +21 -0
  35. package/dist/Support/Injectable.d.ts.map +1 -0
  36. package/dist/Support/Injectable.js +30 -0
  37. package/dist/Support/Injectable.js.map +1 -0
  38. package/dist/index.d.ts +4 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +13 -1
  41. package/dist/index.js.map +1 -1
  42. package/package.json +1 -1
@@ -0,0 +1,100 @@
1
+ /**
2
+ * HasMany Relationship
3
+ *
4
+ * Represents a one-to-many relationship
5
+ */
6
+ import { Ensemble } from '../Ensemble';
7
+ import { EnsembleBuilder } from '../EnsembleBuilder';
8
+ import { EnsembleCollection } from '../EnsembleCollection';
9
+ import { Relation } from './Relation';
10
+ export declare class HasMany<TRelated extends Ensemble, TParent extends Ensemble> extends Relation<TRelated, TParent> {
11
+ /**
12
+ * The foreign key of the parent model
13
+ */
14
+ protected foreignKey: string;
15
+ /**
16
+ * The local key of the parent model
17
+ */
18
+ protected localKey: string;
19
+ /**
20
+ * Create a new has many relationship instance
21
+ */
22
+ constructor(query: EnsembleBuilder<TRelated>, parent: TParent, foreignKey: string, localKey: string);
23
+ /**
24
+ * Set the base constraints on the relation query
25
+ */
26
+ addConstraints(): void;
27
+ /**
28
+ * Set the constraints for an eager load of the relation
29
+ */
30
+ addEagerConstraints(models: TParent[]): void;
31
+ /**
32
+ * Initialize the relation on a set of models
33
+ */
34
+ initRelation(models: TParent[], relation: string): TParent[];
35
+ /**
36
+ * Match the eagerly loaded results to their parents
37
+ */
38
+ match(models: TParent[], results: EnsembleCollection<TRelated>, relation: string): TParent[];
39
+ /**
40
+ * Build model dictionary keyed by the relation's foreign key
41
+ */
42
+ protected buildDictionary(results: EnsembleCollection<TRelated>): Record<any, TRelated[]>;
43
+ /**
44
+ * Get the results of the relationship
45
+ */
46
+ getResults(): Promise<TRelated[]>;
47
+ /**
48
+ * Get the key value of the parent's local key
49
+ */
50
+ protected getParentKey(): any;
51
+ /**
52
+ * Get the foreign key for the relationship
53
+ */
54
+ getForeignKeyName(): string;
55
+ /**
56
+ * Get the local key for the relationship
57
+ */
58
+ getLocalKeyName(): string;
59
+ /**
60
+ * Make a new related instance
61
+ */
62
+ make(attributes?: Record<string, any>): TRelated;
63
+ /**
64
+ * Create a new instance of the related model
65
+ */
66
+ create(attributes?: Record<string, any>): Promise<TRelated>;
67
+ /**
68
+ * Create an array of new instances of the related model
69
+ */
70
+ createMany(records: Record<string, any>[]): Promise<TRelated[]>;
71
+ /**
72
+ * Create a new instance and set the foreign key
73
+ */
74
+ save(model: TRelated): Promise<TRelated>;
75
+ /**
76
+ * Save multiple models with the foreign key set
77
+ */
78
+ saveMany(models: TRelated[]): Promise<TRelated[]>;
79
+ /**
80
+ * Find a related model by its primary key
81
+ */
82
+ find(id: any): Promise<TRelated | null>;
83
+ /**
84
+ * Find multiple related models by their primary keys
85
+ */
86
+ findMany(ids: any[]): Promise<TRelated[]>;
87
+ /**
88
+ * Find a related model by its primary key or throw an exception
89
+ */
90
+ findOrFail(id: any): Promise<TRelated>;
91
+ /**
92
+ * Get the first related model matching the attributes or create it
93
+ */
94
+ firstOrCreate(attributes: Record<string, any>, values?: Record<string, any>): Promise<TRelated>;
95
+ /**
96
+ * Update the parent model on the relationship
97
+ */
98
+ update(attributes: Record<string, any>): Promise<number>;
99
+ }
100
+ //# sourceMappingURL=HasMany.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HasMany.d.ts","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/HasMany.ts"],"names":[],"mappings":"AAAA;;;;GAIG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,IAAI,MAAM;IAIzB;;OAEG;IACH,IAAI,CAAC,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,QAAQ;IAIpD;;OAEG;IACG,MAAM,CAAC,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAarE;;OAEG;IACG,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAUrE;;OAEG;IACG,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAW9C;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAQvD;;OAEG;IACG,IAAI,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAI7C;;OAEG;IACG,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAI/C;;OAEG;IACG,UAAU,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC;IAU5C;;OAEG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBzG;;OAEG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAQ/D"}
@@ -0,0 +1,199 @@
1
+ "use strict";
2
+ /**
3
+ * HasMany Relationship
4
+ *
5
+ * Represents a one-to-many relationship
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.HasMany = void 0;
9
+ const EnsembleCollection_1 = require("../EnsembleCollection");
10
+ const Relation_1 = require("./Relation");
11
+ class HasMany extends Relation_1.Relation {
12
+ /**
13
+ * The foreign key of the parent model
14
+ */
15
+ foreignKey;
16
+ /**
17
+ * The local key of the parent model
18
+ */
19
+ localKey;
20
+ /**
21
+ * Create a new has many relationship instance
22
+ */
23
+ constructor(query, parent, foreignKey, localKey) {
24
+ super(query, parent);
25
+ this.foreignKey = foreignKey;
26
+ this.localKey = localKey;
27
+ }
28
+ /**
29
+ * Set the base constraints on the relation query
30
+ */
31
+ addConstraints() {
32
+ if (Relation_1.Relation['constraints']) {
33
+ this.query.where(this.foreignKey, '=', this.getParentKey());
34
+ }
35
+ }
36
+ /**
37
+ * Set the constraints for an eager load of the relation
38
+ */
39
+ addEagerConstraints(models) {
40
+ const keys = this.getKeys(models, this.localKey);
41
+ this.query.whereIn(this.foreignKey, keys);
42
+ }
43
+ /**
44
+ * Initialize the relation on a set of models
45
+ */
46
+ initRelation(models, relation) {
47
+ for (const model of models) {
48
+ model.setRelation(relation, new EnsembleCollection_1.EnsembleCollection());
49
+ }
50
+ return models;
51
+ }
52
+ /**
53
+ * Match the eagerly loaded results to their parents
54
+ */
55
+ match(models, results, relation) {
56
+ const dictionary = this.buildDictionary(results);
57
+ for (const model of models) {
58
+ const key = model.getAttribute(this.localKey);
59
+ if (key !== null && key !== undefined && dictionary[key]) {
60
+ model.setRelation(relation, new EnsembleCollection_1.EnsembleCollection(dictionary[key]));
61
+ }
62
+ }
63
+ return models;
64
+ }
65
+ /**
66
+ * Build model dictionary keyed by the relation's foreign key
67
+ */
68
+ buildDictionary(results) {
69
+ const dictionary = {};
70
+ for (const result of results) {
71
+ const key = result.getAttribute(this.foreignKey);
72
+ if (key !== null && key !== undefined) {
73
+ if (!dictionary[key]) {
74
+ dictionary[key] = [];
75
+ }
76
+ dictionary[key].push(result);
77
+ }
78
+ }
79
+ return dictionary;
80
+ }
81
+ /**
82
+ * Get the results of the relationship
83
+ */
84
+ async getResults() {
85
+ if (!this.getParentKey()) {
86
+ return [];
87
+ }
88
+ return this.query.get();
89
+ }
90
+ /**
91
+ * Get the key value of the parent's local key
92
+ */
93
+ getParentKey() {
94
+ return this.parent.getAttribute(this.localKey);
95
+ }
96
+ /**
97
+ * Get the foreign key for the relationship
98
+ */
99
+ getForeignKeyName() {
100
+ return this.foreignKey;
101
+ }
102
+ /**
103
+ * Get the local key for the relationship
104
+ */
105
+ getLocalKeyName() {
106
+ return this.localKey;
107
+ }
108
+ /**
109
+ * Make a new related instance
110
+ */
111
+ make(attributes = {}) {
112
+ return this.related.newInstance(attributes);
113
+ }
114
+ /**
115
+ * Create a new instance of the related model
116
+ */
117
+ async create(attributes = {}) {
118
+ const instance = this.make(attributes);
119
+ instance.setAttribute(this.foreignKey, this.getParentKey());
120
+ await instance.save();
121
+ return instance;
122
+ }
123
+ /**
124
+ * Create an array of new instances of the related model
125
+ */
126
+ async createMany(records) {
127
+ const instances = [];
128
+ for (const record of records) {
129
+ instances.push(await this.create(record));
130
+ }
131
+ return instances;
132
+ }
133
+ /**
134
+ * Create a new instance and set the foreign key
135
+ */
136
+ async save(model) {
137
+ model.setAttribute(this.foreignKey, this.getParentKey());
138
+ await model.save();
139
+ return model;
140
+ }
141
+ /**
142
+ * Save multiple models with the foreign key set
143
+ */
144
+ async saveMany(models) {
145
+ for (const model of models) {
146
+ await this.save(model);
147
+ }
148
+ return models;
149
+ }
150
+ /**
151
+ * Find a related model by its primary key
152
+ */
153
+ async find(id) {
154
+ return this.query.where(this.related.getKeyName(), '=', id).first();
155
+ }
156
+ /**
157
+ * Find multiple related models by their primary keys
158
+ */
159
+ async findMany(ids) {
160
+ return this.query.whereIn(this.related.getKeyName(), ids).get();
161
+ }
162
+ /**
163
+ * Find a related model by its primary key or throw an exception
164
+ */
165
+ async findOrFail(id) {
166
+ const result = await this.find(id);
167
+ if (!result) {
168
+ throw new Error(`Model not found with id: ${id}`);
169
+ }
170
+ return result;
171
+ }
172
+ /**
173
+ * Get the first related model matching the attributes or create it
174
+ */
175
+ async firstOrCreate(attributes, values = {}) {
176
+ let query = this.query.clone();
177
+ // Apply each attribute as a where clause
178
+ for (const [key, value] of Object.entries(attributes)) {
179
+ query = query.where(key, '=', value);
180
+ }
181
+ const instance = await query.first();
182
+ if (instance) {
183
+ return instance;
184
+ }
185
+ return this.create({ ...attributes, ...values });
186
+ }
187
+ /**
188
+ * Update the parent model on the relationship
189
+ */
190
+ async update(attributes) {
191
+ const updatedAtColumn = this.related.getUpdatedAtColumn();
192
+ if (updatedAtColumn) {
193
+ attributes[updatedAtColumn] = new Date();
194
+ }
195
+ return this.query.update(attributes);
196
+ }
197
+ }
198
+ exports.HasMany = HasMany;
199
+ //# sourceMappingURL=HasMany.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HasMany.js","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/HasMany.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH,8DAA2D;AAC3D,yCAAsC;AAEtC,MAAa,OAA6D,SAAQ,mBAA2B;IAC3G;;OAEG;IACO,UAAU,CAAS;IAE7B;;OAEG;IACO,QAAQ,CAAS;IAE3B;;OAEG;IACH,YACE,KAAgC,EAChC,MAAe,EACf,UAAkB,EAClB,QAAgB;QAEhB,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,IAAI,mBAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,KAAK,CACd,IAAI,CAAC,UAAU,EACf,GAAG,EACH,IAAI,CAAC,YAAY,EAAE,CACpB,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,MAAiB;QACnC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,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C,KAAK,EAAE,CAAC;QAE/B,yCAAyC;QACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YACtD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QAErC,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,UAA+B;QAC1C,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC1D,IAAI,eAAe,EAAE,CAAC;YACpB,UAAU,CAAC,eAAe,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QAC3C,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;CACF;AAxPD,0BAwPC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * HasOne Relationship
3
+ *
4
+ * Represents a one-to-one relationship
5
+ */
6
+ import { Ensemble } from '../Ensemble';
7
+ import { EnsembleBuilder } from '../EnsembleBuilder';
8
+ import { EnsembleCollection } from '../EnsembleCollection';
9
+ import { Relation } from './Relation';
10
+ export declare class HasOne<TRelated extends Ensemble, TParent extends Ensemble> extends Relation<TRelated, TParent> {
11
+ /**
12
+ * The foreign key of the parent model
13
+ */
14
+ protected foreignKey: string;
15
+ /**
16
+ * The local key of the parent model
17
+ */
18
+ protected localKey: string;
19
+ /**
20
+ * Create a new has one relationship instance
21
+ */
22
+ constructor(query: EnsembleBuilder<TRelated>, parent: TParent, foreignKey: string, localKey: string);
23
+ /**
24
+ * Set the base constraints on the relation query
25
+ */
26
+ addConstraints(): void;
27
+ /**
28
+ * Set the constraints for an eager load of the relation
29
+ */
30
+ addEagerConstraints(models: TParent[]): void;
31
+ /**
32
+ * Initialize the relation on a set of models
33
+ */
34
+ initRelation(models: TParent[], relation: string): TParent[];
35
+ /**
36
+ * Match the eagerly loaded results to their parents
37
+ */
38
+ match(models: TParent[], results: EnsembleCollection<TRelated>, relation: string): TParent[];
39
+ /**
40
+ * Build model dictionary keyed by the relation's foreign key
41
+ */
42
+ protected buildDictionary(results: EnsembleCollection<TRelated>): Record<any, TRelated[]>;
43
+ /**
44
+ * Get the results of the relationship
45
+ */
46
+ getResults(): Promise<TRelated | null>;
47
+ /**
48
+ * Get the key value of the parent's local key
49
+ */
50
+ protected getParentKey(): any;
51
+ /**
52
+ * Get the foreign key for the relationship
53
+ */
54
+ getForeignKeyName(): string;
55
+ /**
56
+ * Get the local key for the relationship
57
+ */
58
+ getLocalKeyName(): string;
59
+ /**
60
+ * Make a new related instance
61
+ */
62
+ make(attributes?: Record<string, any>): TRelated;
63
+ /**
64
+ * Create a new instance of the related model
65
+ */
66
+ create(attributes?: Record<string, any>): Promise<TRelated>;
67
+ /**
68
+ * Create a new instance and set the foreign key
69
+ */
70
+ save(model: TRelated): Promise<TRelated>;
71
+ /**
72
+ * Update the parent model on the relationship
73
+ */
74
+ update(attributes: Record<string, any>): Promise<number>;
75
+ }
76
+ //# sourceMappingURL=HasOne.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HasOne.d.ts","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/HasOne.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,QAAQ,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AAG,CAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAarE;;OAEG;IACG,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAW9C;;OAEG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAQ/D"}
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ /**
3
+ * HasOne Relationship
4
+ *
5
+ * Represents a one-to-one relationship
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.HasOne = void 0;
9
+ const Relation_1 = require("./Relation");
10
+ class HasOne extends Relation_1.Relation {
11
+ /**
12
+ * The foreign key of the parent model
13
+ */
14
+ foreignKey;
15
+ /**
16
+ * The local key of the parent model
17
+ */
18
+ localKey;
19
+ /**
20
+ * Create a new has one relationship instance
21
+ */
22
+ constructor(query, parent, foreignKey, localKey) {
23
+ super(query, parent);
24
+ this.foreignKey = foreignKey;
25
+ this.localKey = localKey;
26
+ }
27
+ /**
28
+ * Set the base constraints on the relation query
29
+ */
30
+ addConstraints() {
31
+ if (Relation_1.Relation['constraints']) {
32
+ this.query.where(this.foreignKey, '=', this.getParentKey());
33
+ }
34
+ }
35
+ /**
36
+ * Set the constraints for an eager load of the relation
37
+ */
38
+ addEagerConstraints(models) {
39
+ const keys = this.getKeys(models, this.localKey);
40
+ this.query.whereIn(this.foreignKey, keys);
41
+ }
42
+ /**
43
+ * Initialize the relation on a set of models
44
+ */
45
+ initRelation(models, relation) {
46
+ for (const model of models) {
47
+ model.setRelation(relation, null);
48
+ }
49
+ return models;
50
+ }
51
+ /**
52
+ * Match the eagerly loaded results to their parents
53
+ */
54
+ match(models, results, relation) {
55
+ const dictionary = this.buildDictionary(results);
56
+ for (const model of models) {
57
+ const key = model.getAttribute(this.localKey);
58
+ if (key !== null && key !== undefined && dictionary[key]) {
59
+ model.setRelation(relation, dictionary[key][0]);
60
+ }
61
+ }
62
+ return models;
63
+ }
64
+ /**
65
+ * Build model dictionary keyed by the relation's foreign key
66
+ */
67
+ buildDictionary(results) {
68
+ const dictionary = {};
69
+ for (const result of results) {
70
+ const key = result.getAttribute(this.foreignKey);
71
+ if (key !== null && key !== undefined) {
72
+ if (!dictionary[key]) {
73
+ dictionary[key] = [];
74
+ }
75
+ dictionary[key].push(result);
76
+ }
77
+ }
78
+ return dictionary;
79
+ }
80
+ /**
81
+ * Get the results of the relationship
82
+ */
83
+ async getResults() {
84
+ if (!this.getParentKey()) {
85
+ return null;
86
+ }
87
+ return this.query.first();
88
+ }
89
+ /**
90
+ * Get the key value of the parent's local key
91
+ */
92
+ getParentKey() {
93
+ return this.parent.getAttribute(this.localKey);
94
+ }
95
+ /**
96
+ * Get the foreign key for the relationship
97
+ */
98
+ getForeignKeyName() {
99
+ return this.foreignKey;
100
+ }
101
+ /**
102
+ * Get the local key for the relationship
103
+ */
104
+ getLocalKeyName() {
105
+ return this.localKey;
106
+ }
107
+ /**
108
+ * Make a new related instance
109
+ */
110
+ make(attributes = {}) {
111
+ return this.related.newInstance(attributes);
112
+ }
113
+ /**
114
+ * Create a new instance of the related model
115
+ */
116
+ async create(attributes = {}) {
117
+ const instance = this.make(attributes);
118
+ instance.setAttribute(this.foreignKey, this.getParentKey());
119
+ await instance.save();
120
+ return instance;
121
+ }
122
+ /**
123
+ * Create a new instance and set the foreign key
124
+ */
125
+ async save(model) {
126
+ model.setAttribute(this.foreignKey, this.getParentKey());
127
+ await model.save();
128
+ return model;
129
+ }
130
+ /**
131
+ * Update the parent model on the relationship
132
+ */
133
+ async update(attributes) {
134
+ const updatedAtColumn = this.related.getUpdatedAtColumn();
135
+ if (updatedAtColumn) {
136
+ attributes[updatedAtColumn] = new Date();
137
+ }
138
+ return this.query.update(attributes);
139
+ }
140
+ }
141
+ exports.HasOne = HasOne;
142
+ //# sourceMappingURL=HasOne.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HasOne.js","source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AEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,aAAkC,EAAE;QACvC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,aAAkC,EAAE;QAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEvC,QAAQ,CAAC,YAAY,CACnB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,YAAY,EAAE,CACpB,CAAC;QAEF,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEtB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,KAAe;QACxB,KAAK,CAAC,YAAY,CAChB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,YAAY,EAAE,CACpB,CAAC;QAEF,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QAEnB,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,UAA+B;QAC1C,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC1D,IAAI,eAAe,EAAE,CAAC;YACpB,UAAU,CAAC,eAAe,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QAC3C,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;CACF;AA9KD,wBA8KC"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Relation Base Class
3
+ *
4
+ * Base class for all relationship types
5
+ */
6
+ import { Ensemble } from '../Ensemble';
7
+ import { EnsembleBuilder } from '../EnsembleBuilder';
8
+ export declare abstract class Relation<TRelated extends Ensemble, TParent extends Ensemble = Ensemble> {
9
+ /**
10
+ * The Ensemble query builder instance
11
+ */
12
+ protected query: EnsembleBuilder<TRelated>;
13
+ /**
14
+ * The parent Ensemble instance
15
+ */
16
+ protected parent: TParent;
17
+ /**
18
+ * The related Ensemble instance
19
+ */
20
+ protected related: TRelated;
21
+ /**
22
+ * Indicates if the relation is adding constraints
23
+ */
24
+ protected static constraints: boolean;
25
+ /**
26
+ * Create a new relation instance
27
+ */
28
+ constructor(query: EnsembleBuilder<TRelated>, parent: TParent);
29
+ /**
30
+ * Set the base constraints on the relation query
31
+ */
32
+ abstract addConstraints(): void;
33
+ /**
34
+ * Set the constraints for an eager load of the relation
35
+ */
36
+ abstract addEagerConstraints(models: TParent[]): void;
37
+ /**
38
+ * Initialize the relation on a set of models
39
+ */
40
+ abstract initRelation(models: TParent[], relation: string): TParent[];
41
+ /**
42
+ * Match the eagerly loaded results to their parents
43
+ */
44
+ abstract match(models: TParent[], results: EnsembleCollection<TRelated>, relation: string): TParent[];
45
+ /**
46
+ * Get the results of the relationship
47
+ */
48
+ abstract getResults(): Promise<TRelated | TRelated[] | null>;
49
+ /**
50
+ * Execute the query as a "select" statement
51
+ */
52
+ get(): Promise<TRelated[]>;
53
+ /**
54
+ * Get the relationship for eager loading
55
+ */
56
+ getEager(): Promise<TRelated[]>;
57
+ /**
58
+ * Touch all of the related models for the relationship
59
+ */
60
+ touch(): Promise<void>;
61
+ /**
62
+ * Run a raw update against the base query
63
+ */
64
+ rawUpdate(attributes?: Record<string, any>): Promise<number>;
65
+ /**
66
+ * Get all of the primary keys for an array of models
67
+ */
68
+ protected getKeys(models: TParent[], key?: string): any[];
69
+ /**
70
+ * Get the underlying query for the relation
71
+ */
72
+ getQuery(): EnsembleBuilder<TRelated>;
73
+ /**
74
+ * Get the base query builder driving the Ensemble builder
75
+ */
76
+ getBaseQuery(): EnsembleBuilder<TRelated>;
77
+ /**
78
+ * Get the parent model of the relation
79
+ */
80
+ getParent(): TParent;
81
+ /**
82
+ * Get the related model of the relation
83
+ */
84
+ getRelated(): TRelated;
85
+ /**
86
+ * Get the name of the "created at" column
87
+ */
88
+ createdAt(): string;
89
+ /**
90
+ * Get the name of the "updated at" column
91
+ */
92
+ updatedAt(): string;
93
+ /**
94
+ * Get the fully qualified related table name
95
+ */
96
+ protected getRelatedTable(): string;
97
+ /**
98
+ * Get the fully qualified parent key name
99
+ */
100
+ protected getQualifiedParentKeyName(): string;
101
+ /**
102
+ * Get the fully qualified foreign key name
103
+ */
104
+ protected getQualifiedForeignKeyName(foreignKey: string): string;
105
+ /**
106
+ * Handle dynamic method calls to the relationship
107
+ */
108
+ __call(method: string, parameters: any[]): any;
109
+ }
110
+ /**
111
+ * Import EnsembleCollection - imported at bottom to avoid circular dependency
112
+ */
113
+ import { EnsembleCollection } from '../EnsembleCollection';
114
+ //# sourceMappingURL=Relation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Relation.d.ts","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/Relation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,8BAAsB,QAAQ,CAAC,QAAQ,SAAS,QAAQ,EAAE,OAAO,SAAS,QAAQ,GAAG,QAAQ;IAC3F;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;IAE3C;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC;IAE5B;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,WAAW,UAAQ;IAEpC;;OAEG;gBACS,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO;IAQ7D;;OAEG;IACH,QAAQ,CAAC,cAAc,IAAI,IAAI;IAE/B;;OAEG;IACH,QAAQ,CAAC,mBAAmB,CAAC,MAA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