@orchestr-sh/orchestr 1.5.1 → 1.5.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.
- package/README.md +119 -6
- package/dist/Database/Ensemble/Concerns/HasRelationships.d.ts +9 -0
- package/dist/Database/Ensemble/Concerns/HasRelationships.d.ts.map +1 -1
- package/dist/Database/Ensemble/Concerns/HasRelationships.js +32 -0
- package/dist/Database/Ensemble/Concerns/HasRelationships.js.map +1 -1
- package/dist/Database/Ensemble/Ensemble.d.ts +6 -1
- package/dist/Database/Ensemble/Ensemble.d.ts.map +1 -1
- package/dist/Database/Ensemble/Ensemble.js +18 -3
- package/dist/Database/Ensemble/Ensemble.js.map +1 -1
- package/dist/Database/Ensemble/EnsembleBuilder.d.ts +4 -0
- package/dist/Database/Ensemble/EnsembleBuilder.d.ts.map +1 -1
- package/dist/Database/Ensemble/EnsembleBuilder.js +12 -1
- package/dist/Database/Ensemble/EnsembleBuilder.js.map +1 -1
- package/dist/Database/Ensemble/Relations/BelongsToMany.d.ts +276 -0
- package/dist/Database/Ensemble/Relations/BelongsToMany.d.ts.map +1 -0
- package/dist/Database/Ensemble/Relations/BelongsToMany.js +540 -0
- package/dist/Database/Ensemble/Relations/BelongsToMany.js.map +1 -0
- package/dist/Database/Ensemble/Relations/index.d.ts +1 -0
- package/dist/Database/Ensemble/Relations/index.d.ts.map +1 -1
- package/dist/Database/Ensemble/Relations/index.js +3 -1
- package/dist/Database/Ensemble/Relations/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* BelongsToMany Relationship
|
|
4
|
+
*
|
|
5
|
+
* Represents a many-to-many relationship
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.BelongsToMany = void 0;
|
|
9
|
+
const EnsembleCollection_1 = require("../EnsembleCollection");
|
|
10
|
+
const Relation_1 = require("./Relation");
|
|
11
|
+
class BelongsToMany extends Relation_1.Relation {
|
|
12
|
+
/**
|
|
13
|
+
* The intermediate table for the relation
|
|
14
|
+
*/
|
|
15
|
+
table;
|
|
16
|
+
/**
|
|
17
|
+
* The foreign key of the parent model
|
|
18
|
+
*/
|
|
19
|
+
foreignPivotKey;
|
|
20
|
+
/**
|
|
21
|
+
* The associated key of the relation
|
|
22
|
+
*/
|
|
23
|
+
relatedPivotKey;
|
|
24
|
+
/**
|
|
25
|
+
* The parent key of the relationship
|
|
26
|
+
*/
|
|
27
|
+
parentKey;
|
|
28
|
+
/**
|
|
29
|
+
* The related key of the relationship
|
|
30
|
+
*/
|
|
31
|
+
relatedKey;
|
|
32
|
+
/**
|
|
33
|
+
* The name of the relationship
|
|
34
|
+
*/
|
|
35
|
+
relationName;
|
|
36
|
+
/**
|
|
37
|
+
* The pivot table columns to retrieve
|
|
38
|
+
*/
|
|
39
|
+
pivotColumns = [];
|
|
40
|
+
/**
|
|
41
|
+
* Any pivot table restrictions
|
|
42
|
+
*/
|
|
43
|
+
pivotWheres = [];
|
|
44
|
+
/**
|
|
45
|
+
* The pivot table values to attach
|
|
46
|
+
*/
|
|
47
|
+
pivotValues = [];
|
|
48
|
+
/**
|
|
49
|
+
* Whether we are using timestamps on the pivot table
|
|
50
|
+
*/
|
|
51
|
+
usingTimestamps = false;
|
|
52
|
+
/**
|
|
53
|
+
* The custom pivot table model
|
|
54
|
+
*/
|
|
55
|
+
using;
|
|
56
|
+
/**
|
|
57
|
+
* The name of the "created at" column
|
|
58
|
+
*/
|
|
59
|
+
pivotCreatedAt;
|
|
60
|
+
/**
|
|
61
|
+
* The name of the "updated at" column
|
|
62
|
+
*/
|
|
63
|
+
pivotUpdatedAt;
|
|
64
|
+
/**
|
|
65
|
+
* The name of the accessor to use for the pivot relationship
|
|
66
|
+
*/
|
|
67
|
+
accessor = 'pivot';
|
|
68
|
+
/**
|
|
69
|
+
* Create a new belongs to many relationship instance
|
|
70
|
+
*/
|
|
71
|
+
constructor(query, parent, table, foreignPivotKey, relatedPivotKey, parentKey, relatedKey, relationName) {
|
|
72
|
+
super(query, parent);
|
|
73
|
+
this.table = table;
|
|
74
|
+
this.foreignPivotKey = foreignPivotKey;
|
|
75
|
+
this.relatedPivotKey = relatedPivotKey;
|
|
76
|
+
this.parentKey = parentKey;
|
|
77
|
+
this.relatedKey = relatedKey;
|
|
78
|
+
this.relationName = relationName || '';
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Set the base constraints on the relation query
|
|
82
|
+
*/
|
|
83
|
+
addConstraints() {
|
|
84
|
+
this.performJoin();
|
|
85
|
+
if (Relation_1.Relation['constraints']) {
|
|
86
|
+
this.addWhereConstraints();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Set the join clause for the relation query
|
|
91
|
+
*/
|
|
92
|
+
performJoin(query) {
|
|
93
|
+
query = query || this.query;
|
|
94
|
+
// Join the pivot table on the related key
|
|
95
|
+
query.join(this.table, `${this.getQualifiedRelatedKeyName()}`, '=', `${this.getQualifiedRelatedPivotKeyName()}`);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Set the where clause for the relation query
|
|
99
|
+
*/
|
|
100
|
+
addWhereConstraints() {
|
|
101
|
+
this.query.where(this.getQualifiedForeignPivotKeyName(), '=', this.parent.getAttribute(this.parentKey));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Set the constraints for an eager load of the relation
|
|
105
|
+
*/
|
|
106
|
+
addEagerConstraints(models) {
|
|
107
|
+
const keys = this.getKeys(models, this.parentKey);
|
|
108
|
+
this.query.whereIn(this.getQualifiedForeignPivotKeyName(), keys);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Initialize the relation on a set of models
|
|
112
|
+
*/
|
|
113
|
+
initRelation(models, relation) {
|
|
114
|
+
for (const model of models) {
|
|
115
|
+
model.setRelation(relation, new EnsembleCollection_1.EnsembleCollection());
|
|
116
|
+
}
|
|
117
|
+
return models;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Match the eagerly loaded results to their parents
|
|
121
|
+
*/
|
|
122
|
+
match(models, results, relation) {
|
|
123
|
+
const dictionary = this.buildDictionary(results);
|
|
124
|
+
for (const model of models) {
|
|
125
|
+
const key = model.getAttribute(this.parentKey);
|
|
126
|
+
if (key !== null && key !== undefined && dictionary[key]) {
|
|
127
|
+
model.setRelation(relation, new EnsembleCollection_1.EnsembleCollection(dictionary[key]));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return models;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Build model dictionary keyed by the relation's foreign key
|
|
134
|
+
*/
|
|
135
|
+
buildDictionary(results) {
|
|
136
|
+
const dictionary = {};
|
|
137
|
+
for (const result of results) {
|
|
138
|
+
const pivotAttributes = this.migratePivotAttributes(result);
|
|
139
|
+
const key = pivotAttributes[this.foreignPivotKey];
|
|
140
|
+
if (key !== null && key !== undefined) {
|
|
141
|
+
if (!dictionary[key]) {
|
|
142
|
+
dictionary[key] = [];
|
|
143
|
+
}
|
|
144
|
+
dictionary[key].push(result);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return dictionary;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get the results of the relationship
|
|
151
|
+
*/
|
|
152
|
+
async getResults() {
|
|
153
|
+
const parentKey = this.parent.getAttribute(this.parentKey);
|
|
154
|
+
if (!parentKey) {
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
return this.get();
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Execute the query and get the models
|
|
161
|
+
*/
|
|
162
|
+
async get() {
|
|
163
|
+
const builder = this.query.addSelect(...this.shouldSelect());
|
|
164
|
+
const models = await builder.get();
|
|
165
|
+
this.hydratePivotRelation(models);
|
|
166
|
+
return models;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get the select columns for the relation query
|
|
170
|
+
*/
|
|
171
|
+
shouldSelect(columns = ['*']) {
|
|
172
|
+
if (columns.length === 1 && columns[0] === '*') {
|
|
173
|
+
columns = [`${this.related.getTable()}.*`];
|
|
174
|
+
}
|
|
175
|
+
return [...columns, ...this.aliasedPivotColumns()];
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get the pivot columns for the relation
|
|
179
|
+
*/
|
|
180
|
+
aliasedPivotColumns() {
|
|
181
|
+
const defaults = [this.foreignPivotKey, this.relatedPivotKey];
|
|
182
|
+
const columns = [...defaults, ...this.pivotColumns];
|
|
183
|
+
return columns.map((column) => {
|
|
184
|
+
return `${this.table}.${column} as pivot_${column}`;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Hydrate the pivot relationship on the models
|
|
189
|
+
*/
|
|
190
|
+
hydratePivotRelation(models) {
|
|
191
|
+
for (const model of models) {
|
|
192
|
+
const pivot = this.migratePivotAttributes(model);
|
|
193
|
+
model.setRelation(this.accessor, pivot);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Migrate the pivot attributes from the model to a pivot model
|
|
198
|
+
*/
|
|
199
|
+
migratePivotAttributes(model) {
|
|
200
|
+
const values = {};
|
|
201
|
+
// Extract all pivot_* attributes
|
|
202
|
+
const attributes = model.attributes || {};
|
|
203
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
204
|
+
if (key.startsWith('pivot_')) {
|
|
205
|
+
const pivotKey = key.substring(6); // Remove 'pivot_' prefix
|
|
206
|
+
values[pivotKey] = value;
|
|
207
|
+
delete model.attributes[key];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return values;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get the fully qualified foreign key for the relation
|
|
214
|
+
*/
|
|
215
|
+
getQualifiedForeignPivotKeyName() {
|
|
216
|
+
return `${this.table}.${this.foreignPivotKey}`;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Get the fully qualified "related key" for the relation
|
|
220
|
+
*/
|
|
221
|
+
getQualifiedRelatedPivotKeyName() {
|
|
222
|
+
return `${this.table}.${this.relatedPivotKey}`;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Get the fully qualified parent key name
|
|
226
|
+
*/
|
|
227
|
+
getQualifiedParentKeyName() {
|
|
228
|
+
return `${this.parent.getTable()}.${this.parentKey}`;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Get the fully qualified related key name
|
|
232
|
+
*/
|
|
233
|
+
getQualifiedRelatedKeyName() {
|
|
234
|
+
return `${this.related.getTable()}.${this.relatedKey}`;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Specify the pivot table columns to retrieve
|
|
238
|
+
*/
|
|
239
|
+
withPivot(...columns) {
|
|
240
|
+
this.pivotColumns = [
|
|
241
|
+
...this.pivotColumns,
|
|
242
|
+
...columns,
|
|
243
|
+
];
|
|
244
|
+
return this;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Indicate that the pivot table has timestamps
|
|
248
|
+
*/
|
|
249
|
+
withTimestamps(createdAt, updatedAt) {
|
|
250
|
+
this.usingTimestamps = true;
|
|
251
|
+
this.pivotCreatedAt = createdAt || 'created_at';
|
|
252
|
+
this.pivotUpdatedAt = updatedAt || 'updated_at';
|
|
253
|
+
return this.withPivot(this.pivotCreatedAt, this.pivotUpdatedAt);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Set a where clause for the pivot table
|
|
257
|
+
*/
|
|
258
|
+
wherePivot(column, operator, value) {
|
|
259
|
+
if (arguments.length === 2) {
|
|
260
|
+
value = operator;
|
|
261
|
+
operator = '=';
|
|
262
|
+
}
|
|
263
|
+
this.pivotWheres.push({
|
|
264
|
+
column: `${this.table}.${column}`,
|
|
265
|
+
operator,
|
|
266
|
+
value,
|
|
267
|
+
boolean: 'and',
|
|
268
|
+
});
|
|
269
|
+
return this.query.where(`${this.table}.${column}`, operator, value);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Set a "where in" clause for the pivot table
|
|
273
|
+
*/
|
|
274
|
+
wherePivotIn(column, values) {
|
|
275
|
+
return this.query.whereIn(`${this.table}.${column}`, values);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Set a "where not in" clause for the pivot table
|
|
279
|
+
*/
|
|
280
|
+
wherePivotNotIn(column, values) {
|
|
281
|
+
return this.query.whereNotIn(`${this.table}.${column}`, values);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Set a "where null" clause for the pivot table
|
|
285
|
+
*/
|
|
286
|
+
wherePivotNull(column) {
|
|
287
|
+
return this.query.whereNull(`${this.table}.${column}`);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Set a "where not null" clause for the pivot table
|
|
291
|
+
*/
|
|
292
|
+
wherePivotNotNull(column) {
|
|
293
|
+
return this.query.whereNotNull(`${this.table}.${column}`);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Set an "or where" clause for the pivot table
|
|
297
|
+
*/
|
|
298
|
+
orWherePivot(column, operator, value) {
|
|
299
|
+
if (arguments.length === 2) {
|
|
300
|
+
value = operator;
|
|
301
|
+
operator = '=';
|
|
302
|
+
}
|
|
303
|
+
return this.query.orWhere(`${this.table}.${column}`, operator, value);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Attach models to the parent
|
|
307
|
+
*/
|
|
308
|
+
async attach(ids, attributes = {}) {
|
|
309
|
+
const records = this.formatAttachRecords(this.parseIds(ids), attributes);
|
|
310
|
+
if (records.length === 0) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const connection = this.parent.getConnection();
|
|
314
|
+
await connection.table(this.table).insert(records);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Detach models from the parent
|
|
318
|
+
*/
|
|
319
|
+
async detach(ids) {
|
|
320
|
+
const connection = this.parent.getConnection();
|
|
321
|
+
let query = connection.table(this.table).where(this.foreignPivotKey, '=', this.parent.getAttribute(this.parentKey));
|
|
322
|
+
if (ids !== undefined) {
|
|
323
|
+
const parsedIds = this.parseIds(ids);
|
|
324
|
+
query = query.whereIn(this.relatedPivotKey, parsedIds);
|
|
325
|
+
}
|
|
326
|
+
return await query.delete();
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Sync the intermediate tables with a list of IDs
|
|
330
|
+
*/
|
|
331
|
+
async sync(ids) {
|
|
332
|
+
const changes = {
|
|
333
|
+
attached: [],
|
|
334
|
+
detached: [],
|
|
335
|
+
updated: [],
|
|
336
|
+
};
|
|
337
|
+
const current = await this.getCurrentlyAttachedPivots();
|
|
338
|
+
const records = this.formatRecordsList(this.parseIds(ids));
|
|
339
|
+
const detach = current.filter((id) => !records.some((record) => record.id === id));
|
|
340
|
+
if (detach.length > 0) {
|
|
341
|
+
await this.detach(detach);
|
|
342
|
+
changes.detached = detach;
|
|
343
|
+
}
|
|
344
|
+
changes.attached = await this.attachNew(records, current);
|
|
345
|
+
changes.updated = await this.updateExisting(records, current);
|
|
346
|
+
return changes;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Sync without detaching
|
|
350
|
+
*/
|
|
351
|
+
async syncWithoutDetaching(ids) {
|
|
352
|
+
const changes = {
|
|
353
|
+
attached: [],
|
|
354
|
+
updated: [],
|
|
355
|
+
};
|
|
356
|
+
const current = await this.getCurrentlyAttachedPivots();
|
|
357
|
+
const records = this.formatRecordsList(this.parseIds(ids));
|
|
358
|
+
changes.attached = await this.attachNew(records, current);
|
|
359
|
+
changes.updated = await this.updateExisting(records, current);
|
|
360
|
+
return changes;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Toggle models from the parent
|
|
364
|
+
*/
|
|
365
|
+
async toggle(ids) {
|
|
366
|
+
const changes = {
|
|
367
|
+
attached: [],
|
|
368
|
+
detached: [],
|
|
369
|
+
};
|
|
370
|
+
const parsedIds = this.parseIds(ids);
|
|
371
|
+
const current = await this.getCurrentlyAttachedPivots();
|
|
372
|
+
const detach = parsedIds.filter((id) => current.includes(id));
|
|
373
|
+
const attach = parsedIds.filter((id) => !current.includes(id));
|
|
374
|
+
if (detach.length > 0) {
|
|
375
|
+
await this.detach(detach);
|
|
376
|
+
changes.detached = detach;
|
|
377
|
+
}
|
|
378
|
+
if (attach.length > 0) {
|
|
379
|
+
await this.attach(attach);
|
|
380
|
+
changes.attached = attach;
|
|
381
|
+
}
|
|
382
|
+
return changes;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Update an existing pivot record on the table
|
|
386
|
+
*/
|
|
387
|
+
async updateExistingPivot(id, attributes) {
|
|
388
|
+
if (this.usingTimestamps && this.pivotUpdatedAt) {
|
|
389
|
+
attributes[this.pivotUpdatedAt] = new Date();
|
|
390
|
+
}
|
|
391
|
+
const connection = this.parent.getConnection();
|
|
392
|
+
return await connection
|
|
393
|
+
.table(this.table)
|
|
394
|
+
.where(this.foreignPivotKey, '=', this.parent.getAttribute(this.parentKey))
|
|
395
|
+
.where(this.relatedPivotKey, '=', id)
|
|
396
|
+
.update(attributes);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Get the currently attached pivot IDs
|
|
400
|
+
*/
|
|
401
|
+
async getCurrentlyAttachedPivots() {
|
|
402
|
+
const connection = this.parent.getConnection();
|
|
403
|
+
const results = await connection
|
|
404
|
+
.table(this.table)
|
|
405
|
+
.where(this.foreignPivotKey, '=', this.parent.getAttribute(this.parentKey))
|
|
406
|
+
.pluck(this.relatedPivotKey);
|
|
407
|
+
return results;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Attach new records
|
|
411
|
+
*/
|
|
412
|
+
async attachNew(records, current) {
|
|
413
|
+
const newRecords = records.filter((record) => !current.includes(record.id));
|
|
414
|
+
if (newRecords.length === 0) {
|
|
415
|
+
return [];
|
|
416
|
+
}
|
|
417
|
+
await this.attach(newRecords.map((r) => r.id), newRecords[0]?.attributes || {});
|
|
418
|
+
return newRecords.map((r) => r.id);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Update existing records
|
|
422
|
+
*/
|
|
423
|
+
async updateExisting(records, current) {
|
|
424
|
+
const updated = [];
|
|
425
|
+
for (const record of records) {
|
|
426
|
+
if (current.includes(record.id) && Object.keys(record.attributes).length > 0) {
|
|
427
|
+
await this.updateExistingPivot(record.id, record.attributes);
|
|
428
|
+
updated.push(record.id);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return updated;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Format the records for attaching
|
|
435
|
+
*/
|
|
436
|
+
formatAttachRecords(ids, attributes) {
|
|
437
|
+
const records = [];
|
|
438
|
+
const hasTimestamps = this.usingTimestamps;
|
|
439
|
+
for (const id of ids) {
|
|
440
|
+
const record = {
|
|
441
|
+
[this.foreignPivotKey]: this.parent.getAttribute(this.parentKey),
|
|
442
|
+
[this.relatedPivotKey]: id,
|
|
443
|
+
...attributes,
|
|
444
|
+
};
|
|
445
|
+
if (hasTimestamps) {
|
|
446
|
+
const now = new Date();
|
|
447
|
+
if (this.pivotCreatedAt) {
|
|
448
|
+
record[this.pivotCreatedAt] = now;
|
|
449
|
+
}
|
|
450
|
+
if (this.pivotUpdatedAt) {
|
|
451
|
+
record[this.pivotUpdatedAt] = now;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
records.push(record);
|
|
455
|
+
}
|
|
456
|
+
return records;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Format the sync records
|
|
460
|
+
*/
|
|
461
|
+
formatRecordsList(ids) {
|
|
462
|
+
return ids.map((id) => {
|
|
463
|
+
if (typeof id === 'object' && !Array.isArray(id)) {
|
|
464
|
+
const { id: recordId, ...attributes } = id;
|
|
465
|
+
return { id: recordId, attributes };
|
|
466
|
+
}
|
|
467
|
+
return { id, attributes: {} };
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Parse the IDs from the given value
|
|
472
|
+
*/
|
|
473
|
+
parseIds(value) {
|
|
474
|
+
if (value instanceof EnsembleCollection_1.EnsembleCollection) {
|
|
475
|
+
return value.modelKeys();
|
|
476
|
+
}
|
|
477
|
+
if (Array.isArray(value)) {
|
|
478
|
+
return value;
|
|
479
|
+
}
|
|
480
|
+
if (typeof value === 'object' && value !== null) {
|
|
481
|
+
// Handle {id: attributes} format
|
|
482
|
+
return Object.keys(value).map((key) => {
|
|
483
|
+
const id = isNaN(Number(key)) ? key : Number(key);
|
|
484
|
+
return { id, ...value[key] };
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
return [value];
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Get the name of the pivot accessor
|
|
491
|
+
*/
|
|
492
|
+
getPivotAccessor() {
|
|
493
|
+
return this.accessor;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Set the name of the pivot accessor
|
|
497
|
+
*/
|
|
498
|
+
as(accessor) {
|
|
499
|
+
this.accessor = accessor;
|
|
500
|
+
return this;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Get the pivot table name
|
|
504
|
+
*/
|
|
505
|
+
getTable() {
|
|
506
|
+
return this.table;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Get the foreign pivot key name
|
|
510
|
+
*/
|
|
511
|
+
getForeignPivotKeyName() {
|
|
512
|
+
return this.foreignPivotKey;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Get the related pivot key name
|
|
516
|
+
*/
|
|
517
|
+
getRelatedPivotKeyName() {
|
|
518
|
+
return this.relatedPivotKey;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Get the parent key name
|
|
522
|
+
*/
|
|
523
|
+
getParentKeyName() {
|
|
524
|
+
return this.parentKey;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Get the related key name
|
|
528
|
+
*/
|
|
529
|
+
getRelatedKeyName() {
|
|
530
|
+
return this.relatedKey;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Get the relationship name
|
|
534
|
+
*/
|
|
535
|
+
getRelationName() {
|
|
536
|
+
return this.relationName;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
exports.BelongsToMany = BelongsToMany;
|
|
540
|
+
//# sourceMappingURL=BelongsToMany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BelongsToMany.js","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/BelongsToMany.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH,8DAA2D;AAC3D,yCAAsC;AAEtC,MAAa,aAAmE,SAAQ,mBAA2B;IACjH;;OAEG;IACO,KAAK,CAAS;IAExB;;OAEG;IACO,eAAe,CAAS;IAElC;;OAEG;IACO,eAAe,CAAS;IAElC;;OAEG;IACO,SAAS,CAAS;IAE5B;;OAEG;IACO,UAAU,CAAS;IAE7B;;OAEG;IACO,YAAY,CAAS;IAE/B;;OAEG;IACO,YAAY,GAAa,EAAE,CAAC;IAEtC;;OAEG;IACO,WAAW,GAA+E,EAAE,CAAC;IAEvG;;OAEG;IACO,WAAW,GAA0B,EAAE,CAAC;IAElD;;OAEG;IACO,eAAe,GAAY,KAAK,CAAC;IAE3C;;OAEG;IACO,KAAK,CAAO;IAEtB;;OAEG;IACO,cAAc,CAAU;IAElC;;OAEG;IACO,cAAc,CAAU;IAElC;;OAEG;IACO,QAAQ,GAAW,OAAO,CAAC;IAErC;;OAEG;IACH,YACE,KAAgC,EAChC,MAAe,EACf,KAAa,EACb,eAAuB,EACvB,eAAuB,EACvB,SAAiB,EACjB,UAAkB,EAClB,YAAqB;QAErB,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAA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B,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;CACF;AAlrBD,sCAkrBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Export all relationship classes
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.BelongsTo = exports.HasMany = exports.HasOne = exports.Relation = void 0;
|
|
8
|
+
exports.BelongsToMany = exports.BelongsTo = exports.HasMany = exports.HasOne = exports.Relation = void 0;
|
|
9
9
|
var Relation_1 = require("./Relation");
|
|
10
10
|
Object.defineProperty(exports, "Relation", { enumerable: true, get: function () { return Relation_1.Relation; } });
|
|
11
11
|
var HasOne_1 = require("./HasOne");
|
|
@@ -14,4 +14,6 @@ var HasMany_1 = require("./HasMany");
|
|
|
14
14
|
Object.defineProperty(exports, "HasMany", { enumerable: true, get: function () { return HasMany_1.HasMany; } });
|
|
15
15
|
var BelongsTo_1 = require("./BelongsTo");
|
|
16
16
|
Object.defineProperty(exports, "BelongsTo", { enumerable: true, get: function () { return BelongsTo_1.BelongsTo; } });
|
|
17
|
+
var BelongsToMany_1 = require("./BelongsToMany");
|
|
18
|
+
Object.defineProperty(exports, "BelongsToMany", { enumerable: true, get: function () { return BelongsToMany_1.BelongsToMany; } });
|
|
17
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA"}
|
package/package.json
CHANGED