pinia-orm-edge 1.10.0-28693042.c6e88ef → 1.10.0-28693841.a86c2d9

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/dist/casts.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.e4d337f9.cjs';
1
+ import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.90cdba8c.cjs';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
package/dist/casts.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.e4d337f9.mjs';
1
+ import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.90cdba8c.mjs';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
package/dist/casts.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.e4d337f9.js';
1
+ import { a0 as CastAttribute, m as ModelFields } from './shared/pinia-orm.90cdba8c.js';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
@@ -78,7 +78,12 @@ function BelongsToMany(related, pivot, foreignPivotKey, relatedPivotKey, parentK
78
78
  const self = target.$self();
79
79
  self.setRegistry(
80
80
  propertyKey,
81
- () => self.belongsToMany(related(), pivot(), foreignPivotKey, relatedPivotKey, parentKey, relatedKey)
81
+ () => {
82
+ if (typeof pivot === "function") {
83
+ return self.belongsToMany(related(), pivot(), foreignPivotKey, relatedPivotKey, parentKey, relatedKey);
84
+ }
85
+ return self.belongsToMany(related(), pivot.model(), foreignPivotKey, relatedPivotKey, parentKey, relatedKey).as(pivot.as);
86
+ }
82
87
  );
83
88
  };
84
89
  }
@@ -136,20 +141,24 @@ function MorphTo(related, id, type, ownerKey) {
136
141
  function MorphToMany(related, pivot, relatedId, id, type, parentKey, relatedKey) {
137
142
  return (target, propertyKey) => {
138
143
  const self = target.$self();
139
- self.setRegistry(
140
- propertyKey,
141
- () => self.morphToMany(related(), pivot(), relatedId, id, type, parentKey, relatedKey)
142
- );
144
+ self.setRegistry(propertyKey, () => {
145
+ if (typeof pivot === "function") {
146
+ return self.morphToMany(related(), pivot(), relatedId, id, type, parentKey, relatedKey);
147
+ }
148
+ return self.morphToMany(related(), pivot.model(), relatedId, id, type, parentKey, relatedKey).as(pivot.as);
149
+ });
143
150
  };
144
151
  }
145
152
 
146
153
  function MorphedByMany(related, pivot, relatedId, id, type, parentKey, relatedKey) {
147
154
  return (target, propertyKey) => {
148
155
  const self = target.$self();
149
- self.setRegistry(
150
- propertyKey,
151
- () => self.morphedByMany(related(), pivot(), relatedId, id, type, parentKey, relatedKey)
152
- );
156
+ self.setRegistry(propertyKey, () => {
157
+ if (typeof pivot === "function") {
158
+ return self.morphedByMany(related(), pivot(), relatedId, id, type, parentKey, relatedKey);
159
+ }
160
+ return self.morphedByMany(related(), pivot.model(), relatedId, id, type, parentKey, relatedKey).as(pivot.as);
161
+ });
153
162
  };
154
163
  }
155
164
 
@@ -1,5 +1,5 @@
1
- import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.e4d337f9.cjs';
2
- export { aq as NanoidOptions } from './shared/pinia-orm.e4d337f9.cjs';
1
+ import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.90cdba8c.cjs';
2
+ export { aq as NanoidOptions } from './shared/pinia-orm.90cdba8c.cjs';
3
3
  import 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
@@ -42,7 +42,10 @@ declare function BelongsTo(related: () => typeof Model, foreignKey: PrimaryKey,
42
42
  /**
43
43
  * Create a belongs-to-many attribute property decorator.
44
44
  */
45
- declare function BelongsToMany(related: () => typeof Model, pivot: () => typeof Model, foreignPivotKey: string, relatedPivotKey: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
45
+ declare function BelongsToMany(related: () => typeof Model, pivot: (() => typeof Model) | {
46
+ as: string;
47
+ model: () => typeof Model;
48
+ }, foreignPivotKey: string, relatedPivotKey: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
46
49
 
47
50
  /**
48
51
  * Create a has-many attribute property decorator.
@@ -72,12 +75,18 @@ declare function MorphTo(related: () => typeof Model[], id: string, type: string
72
75
  /**
73
76
  * Create a morph-to-many attribute property decorator.
74
77
  */
75
- declare function MorphToMany(related: () => typeof Model, pivot: () => typeof Model, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
78
+ declare function MorphToMany(related: () => typeof Model, pivot: (() => typeof Model) | {
79
+ as: string;
80
+ model: () => typeof Model;
81
+ }, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
76
82
 
77
83
  /**
78
84
  * Create a morph-to-many attribute property decorator.
79
85
  */
80
- declare function MorphedByMany(related: () => typeof Model, pivot: () => typeof Model, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
86
+ declare function MorphedByMany(related: () => typeof Model, pivot: (() => typeof Model) | {
87
+ as: string;
88
+ model: () => typeof Model;
89
+ }, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
81
90
 
82
91
  /**
83
92
  * Create a morph-many attribute property decorator.
@@ -1,5 +1,5 @@
1
- import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.e4d337f9.mjs';
2
- export { aq as NanoidOptions } from './shared/pinia-orm.e4d337f9.mjs';
1
+ import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.90cdba8c.mjs';
2
+ export { aq as NanoidOptions } from './shared/pinia-orm.90cdba8c.mjs';
3
3
  import 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
@@ -42,7 +42,10 @@ declare function BelongsTo(related: () => typeof Model, foreignKey: PrimaryKey,
42
42
  /**
43
43
  * Create a belongs-to-many attribute property decorator.
44
44
  */
45
- declare function BelongsToMany(related: () => typeof Model, pivot: () => typeof Model, foreignPivotKey: string, relatedPivotKey: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
45
+ declare function BelongsToMany(related: () => typeof Model, pivot: (() => typeof Model) | {
46
+ as: string;
47
+ model: () => typeof Model;
48
+ }, foreignPivotKey: string, relatedPivotKey: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
46
49
 
47
50
  /**
48
51
  * Create a has-many attribute property decorator.
@@ -72,12 +75,18 @@ declare function MorphTo(related: () => typeof Model[], id: string, type: string
72
75
  /**
73
76
  * Create a morph-to-many attribute property decorator.
74
77
  */
75
- declare function MorphToMany(related: () => typeof Model, pivot: () => typeof Model, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
78
+ declare function MorphToMany(related: () => typeof Model, pivot: (() => typeof Model) | {
79
+ as: string;
80
+ model: () => typeof Model;
81
+ }, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
76
82
 
77
83
  /**
78
84
  * Create a morph-to-many attribute property decorator.
79
85
  */
80
- declare function MorphedByMany(related: () => typeof Model, pivot: () => typeof Model, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
86
+ declare function MorphedByMany(related: () => typeof Model, pivot: (() => typeof Model) | {
87
+ as: string;
88
+ model: () => typeof Model;
89
+ }, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
81
90
 
82
91
  /**
83
92
  * Create a morph-many attribute property decorator.
@@ -1,5 +1,5 @@
1
- import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.e4d337f9.js';
2
- export { aq as NanoidOptions } from './shared/pinia-orm.e4d337f9.js';
1
+ import { a1 as TypeDefault, an as PropertyDecorator, ao as TypeOptions, ap as UidOptions, M as Model, s as PrimaryKey, H as deleteModes, a0 as CastAttribute, aj as Mutator } from './shared/pinia-orm.90cdba8c.js';
2
+ export { aq as NanoidOptions } from './shared/pinia-orm.90cdba8c.js';
3
3
  import 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
@@ -42,7 +42,10 @@ declare function BelongsTo(related: () => typeof Model, foreignKey: PrimaryKey,
42
42
  /**
43
43
  * Create a belongs-to-many attribute property decorator.
44
44
  */
45
- declare function BelongsToMany(related: () => typeof Model, pivot: () => typeof Model, foreignPivotKey: string, relatedPivotKey: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
45
+ declare function BelongsToMany(related: () => typeof Model, pivot: (() => typeof Model) | {
46
+ as: string;
47
+ model: () => typeof Model;
48
+ }, foreignPivotKey: string, relatedPivotKey: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
46
49
 
47
50
  /**
48
51
  * Create a has-many attribute property decorator.
@@ -72,12 +75,18 @@ declare function MorphTo(related: () => typeof Model[], id: string, type: string
72
75
  /**
73
76
  * Create a morph-to-many attribute property decorator.
74
77
  */
75
- declare function MorphToMany(related: () => typeof Model, pivot: () => typeof Model, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
78
+ declare function MorphToMany(related: () => typeof Model, pivot: (() => typeof Model) | {
79
+ as: string;
80
+ model: () => typeof Model;
81
+ }, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
76
82
 
77
83
  /**
78
84
  * Create a morph-to-many attribute property decorator.
79
85
  */
80
- declare function MorphedByMany(related: () => typeof Model, pivot: () => typeof Model, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
86
+ declare function MorphedByMany(related: () => typeof Model, pivot: (() => typeof Model) | {
87
+ as: string;
88
+ model: () => typeof Model;
89
+ }, relatedId: string, id: string, type: string, parentKey?: string, relatedKey?: string): PropertyDecorator;
81
90
 
82
91
  /**
83
92
  * Create a morph-many attribute property decorator.
@@ -76,7 +76,12 @@ function BelongsToMany(related, pivot, foreignPivotKey, relatedPivotKey, parentK
76
76
  const self = target.$self();
77
77
  self.setRegistry(
78
78
  propertyKey,
79
- () => self.belongsToMany(related(), pivot(), foreignPivotKey, relatedPivotKey, parentKey, relatedKey)
79
+ () => {
80
+ if (typeof pivot === "function") {
81
+ return self.belongsToMany(related(), pivot(), foreignPivotKey, relatedPivotKey, parentKey, relatedKey);
82
+ }
83
+ return self.belongsToMany(related(), pivot.model(), foreignPivotKey, relatedPivotKey, parentKey, relatedKey).as(pivot.as);
84
+ }
80
85
  );
81
86
  };
82
87
  }
@@ -134,20 +139,24 @@ function MorphTo(related, id, type, ownerKey) {
134
139
  function MorphToMany(related, pivot, relatedId, id, type, parentKey, relatedKey) {
135
140
  return (target, propertyKey) => {
136
141
  const self = target.$self();
137
- self.setRegistry(
138
- propertyKey,
139
- () => self.morphToMany(related(), pivot(), relatedId, id, type, parentKey, relatedKey)
140
- );
142
+ self.setRegistry(propertyKey, () => {
143
+ if (typeof pivot === "function") {
144
+ return self.morphToMany(related(), pivot(), relatedId, id, type, parentKey, relatedKey);
145
+ }
146
+ return self.morphToMany(related(), pivot.model(), relatedId, id, type, parentKey, relatedKey).as(pivot.as);
147
+ });
141
148
  };
142
149
  }
143
150
 
144
151
  function MorphedByMany(related, pivot, relatedId, id, type, parentKey, relatedKey) {
145
152
  return (target, propertyKey) => {
146
153
  const self = target.$self();
147
- self.setRegistry(
148
- propertyKey,
149
- () => self.morphedByMany(related(), pivot(), relatedId, id, type, parentKey, relatedKey)
150
- );
154
+ self.setRegistry(propertyKey, () => {
155
+ if (typeof pivot === "function") {
156
+ return self.morphedByMany(related(), pivot(), relatedId, id, type, parentKey, relatedKey);
157
+ }
158
+ return self.morphedByMany(related(), pivot.model(), relatedId, id, type, parentKey, relatedKey).as(pivot.as);
159
+ });
151
160
  };
152
161
  }
153
162
 
@@ -1,4 +1,4 @@
1
- import { M as Model, b as Collection } from './shared/pinia-orm.e4d337f9.cjs';
1
+ import { M as Model, b as Collection } from './shared/pinia-orm.90cdba8c.cjs';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
@@ -1,4 +1,4 @@
1
- import { M as Model, b as Collection } from './shared/pinia-orm.e4d337f9.mjs';
1
+ import { M as Model, b as Collection } from './shared/pinia-orm.90cdba8c.mjs';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
package/dist/helpers.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as Model, b as Collection } from './shared/pinia-orm.e4d337f9.js';
1
+ import { M as Model, b as Collection } from './shared/pinia-orm.90cdba8c.js';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
package/dist/index.cjs CHANGED
@@ -652,7 +652,7 @@ class BelongsToMany extends Relation {
652
652
  * Attach the parent type and id to the given relation.
653
653
  */
654
654
  attach(record, child) {
655
- const pivot = child.pivot ?? {};
655
+ const pivot = child[this.pivotKey] ?? {};
656
656
  pivot[this.foreignPivotKey] = record[this.parentKey];
657
657
  pivot[this.relatedPivotKey] = child[this.relatedKey];
658
658
  child[`pivot_${this.relatedPivotKey}_${this.pivot.$entity()}`] = pivot;
@@ -677,10 +677,11 @@ class BelongsToMany extends Relation {
677
677
  return;
678
678
  }
679
679
  const relatedModelCopy = relatedModel.$newInstance(relatedModel.$toJson(), { operation: void 0 });
680
- relatedModelCopy.$setRelation("pivot", pivot);
680
+ relatedModelCopy.$setRelation(this.pivotKey, pivot, true);
681
681
  relationResults.push(relatedModelCopy);
682
682
  });
683
683
  parentModel.$setRelation(relation, relationResults);
684
+ parentModel.$setRelation(this.pivotKey, void 0);
684
685
  });
685
686
  }
686
687
  /**
@@ -688,6 +689,13 @@ class BelongsToMany extends Relation {
688
689
  */
689
690
  addEagerConstraints(_query, _collection) {
690
691
  }
692
+ /**
693
+ * Specify the custom pivot accessor to use for the relationship.
694
+ */
695
+ as(accessor) {
696
+ this.pivotKey = accessor;
697
+ return this;
698
+ }
691
699
  }
692
700
 
693
701
  var __defProp$d = Object.defineProperty;
@@ -2812,7 +2820,7 @@ class MorphToMany extends Relation {
2812
2820
  * Attach the parent type and id to the given relation.
2813
2821
  */
2814
2822
  attach(record, child) {
2815
- const pivot = child.pivot ?? {};
2823
+ const pivot = child[this.pivotKey] ?? {};
2816
2824
  pivot[this.morphId] = record[this.parentKey];
2817
2825
  pivot[this.morphType] = this.parent.$entity();
2818
2826
  pivot[this.relatedId] = child[this.relatedKey];
@@ -2835,7 +2843,7 @@ class MorphToMany extends Relation {
2835
2843
  relatedModels.forEach((relatedModel) => {
2836
2844
  const pivot = pivotModels[`[${parentModel[this.parentKey]},${relatedModel[this.relatedKey]},${this.parent.$entity()}]`]?.[0] ?? null;
2837
2845
  const relatedModelCopy = relatedModel.$newInstance(relatedModel.$toJson(), { operation: void 0 });
2838
- relatedModelCopy.$setRelation("pivot", pivot);
2846
+ relatedModelCopy.$setRelation(this.pivotKey, pivot, true);
2839
2847
  if (pivot) {
2840
2848
  relationResults.push(relatedModelCopy);
2841
2849
  }
@@ -2848,6 +2856,13 @@ class MorphToMany extends Relation {
2848
2856
  */
2849
2857
  addEagerConstraints(_query, _collection) {
2850
2858
  }
2859
+ /**
2860
+ * Specify the custom pivot accessor to use for the relationship.
2861
+ */
2862
+ as(accessor) {
2863
+ this.pivotKey = accessor;
2864
+ return this;
2865
+ }
2851
2866
  }
2852
2867
 
2853
2868
  var __defProp$1 = Object.defineProperty;
@@ -2913,7 +2928,7 @@ class MorphedByMany extends Relation {
2913
2928
  * Attach the parent type and id to the given relation.
2914
2929
  */
2915
2930
  attach(record, child) {
2916
- const pivot = record.pivot ?? {};
2931
+ const pivot = record[this.pivotKey] ?? {};
2917
2932
  pivot[this.morphId] = child[this.relatedKey];
2918
2933
  pivot[this.morphType] = this.related.$entity();
2919
2934
  pivot[this.relatedId] = record[this.parentKey];
@@ -2932,18 +2947,13 @@ class MorphedByMany extends Relation {
2932
2947
  const relatedModels = query.get(false);
2933
2948
  const pivotModels = query.newQuery(this.pivot.$modelEntity()).whereIn(this.relatedId, this.getKeys(models, this.parentKey)).whereIn(this.morphId, this.getKeys(relatedModels, this.relatedKey)).groupBy(this.relatedId, this.morphType).get();
2934
2949
  models.forEach((parentModel) => {
2935
- const relationResults = [];
2936
2950
  const resultModelIds = this.getKeys(pivotModels[`[${parentModel[this.parentKey]},${this.related.$entity()}]`] ?? [], this.morphId);
2937
2951
  const relatedModelsFiltered = relatedModels.filter((filterdModel) => resultModelIds.includes(filterdModel[this.relatedKey]));
2938
- relatedModelsFiltered.forEach((relatedModel) => {
2939
- const pivot = (pivotModels[`[${parentModel[this.parentKey]},${this.related.$entity()}]`] ?? []).find((pivotModel) => pivotModel[this.morphId] === relatedModel[this.relatedKey]) ?? null;
2940
- const relatedModelCopy = relatedModel.$newInstance(relatedModel.$toJson(), { operation: void 0 });
2941
- if (pivot) {
2942
- relatedModelCopy.$setRelation("pivot", pivot);
2943
- }
2944
- relationResults.push(relatedModelCopy);
2945
- });
2946
- parentModel.$setRelation(relation, relationResults);
2952
+ const pivot = (pivotModels[`[${parentModel[this.parentKey]},${this.related.$entity()}]`] ?? [])?.[0] ?? null;
2953
+ if (pivot) {
2954
+ parentModel.$setRelation(this.pivotKey, pivot, true);
2955
+ }
2956
+ parentModel.$setRelation(relation, relatedModelsFiltered);
2947
2957
  });
2948
2958
  }
2949
2959
  /**
@@ -2951,6 +2961,13 @@ class MorphedByMany extends Relation {
2951
2961
  */
2952
2962
  addEagerConstraints(_query, _collection) {
2953
2963
  }
2964
+ /**
2965
+ * Specify the custom pivot accessor to use for the relationship.
2966
+ */
2967
+ as(accessor) {
2968
+ this.pivotKey = accessor;
2969
+ return this;
2970
+ }
2954
2971
  }
2955
2972
 
2956
2973
  var __defProp = Object.defineProperty;
@@ -2964,8 +2981,6 @@ class Model {
2964
2981
  * Create a new model instance.
2965
2982
  */
2966
2983
  constructor(attributes, options = { operation: "set" }) {
2967
- // [s: keyof ModelFields]: any
2968
- __publicField(this, "pivot");
2969
2984
  this.$boot();
2970
2985
  const fill = options.fill ?? true;
2971
2986
  fill && this.$fill(attributes, options);
@@ -3537,12 +3552,8 @@ class Model {
3537
3552
  /**
3538
3553
  * Set the given relationship on the model.
3539
3554
  */
3540
- $setRelation(relation, model) {
3541
- if (relation.includes("pivot")) {
3542
- this.pivot = model;
3543
- return this;
3544
- }
3545
- if (this.$fields()[relation]) {
3555
+ $setRelation(relation, model, isPivot = false) {
3556
+ if (this.$fields()[relation] || isPivot) {
3546
3557
  this[relation] = model;
3547
3558
  }
3548
3559
  return this;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.e4d337f9.cjs';
2
- export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.e4d337f9.cjs';
1
+ import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.90cdba8c.cjs';
2
+ export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.90cdba8c.cjs';
3
3
  import { Pinia } from 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.e4d337f9.mjs';
2
- export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.e4d337f9.mjs';
1
+ import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.90cdba8c.mjs';
2
+ export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.90cdba8c.mjs';
3
3
  import { Pinia } from 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.e4d337f9.js';
2
- export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.e4d337f9.js';
1
+ import { R as Repository, C as Constructor, M as Model, Q as Query, D as DataStore, E as Elements, W as WeakCache, F as FilledInstallOptions } from './shared/pinia-orm.90cdba8c.js';
2
+ export { A as AfterHook, y as Attribute, B as BeforeHook, K as BelongsTo, L as BelongsToMany, am as CacheConfig, g as CacheConfigOptions, a0 as CastAttribute, $ as Casts, b as Collection, i as CreatePiniaOrm, c as DataStoreState, k as Database, z as Dictionary, ah as EagerLoad, ai as EagerLoadConstraint, a as Element, a6 as GetElementType, ac as Group, ae as GroupBy, af as GroupByFields, G as GroupedCollection, O as HasMany, U as HasManyBy, V as HasManyThrough, T as HasOne, w as InheritanceTypes, h as InstallOptions, a3 as Interpreter, I as Item, v as MetaValues, f as ModelConfigOptions, m as ModelFields, t as ModelOptions, o as ModelRegistries, q as ModelRegistry, n as ModelSchemas, X as MorphMany, _ as MorphOne, Y as MorphTo, Z as MorphToMany, aj as Mutator, ak as MutatorFunctions, al as Mutators, a5 as NonMethodKeys, N as NormalizedData, ab as Order, ad as OrderBy, ag as OrderDirection, d as PiniaOrmPlugin, P as PiniaOrmPluginContext, s as PrimaryKey, J as Relation, l as Schema, S as Schemas, a2 as Type, a1 as TypeDefault, a7 as UltimateKeys, a4 as Where, aa as WhereGroup, a8 as WherePrimaryClosure, a9 as WhereSecondaryClosure, x as WithKeys, j as createORM, e as definePiniaOrmPlugin, H as deleteModes, p as plugins, r as registerPlugins, u as useDataStore } from './shared/pinia-orm.90cdba8c.js';
3
3
  import { Pinia } from 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
package/dist/index.mjs CHANGED
@@ -650,7 +650,7 @@ class BelongsToMany extends Relation {
650
650
  * Attach the parent type and id to the given relation.
651
651
  */
652
652
  attach(record, child) {
653
- const pivot = child.pivot ?? {};
653
+ const pivot = child[this.pivotKey] ?? {};
654
654
  pivot[this.foreignPivotKey] = record[this.parentKey];
655
655
  pivot[this.relatedPivotKey] = child[this.relatedKey];
656
656
  child[`pivot_${this.relatedPivotKey}_${this.pivot.$entity()}`] = pivot;
@@ -675,10 +675,11 @@ class BelongsToMany extends Relation {
675
675
  return;
676
676
  }
677
677
  const relatedModelCopy = relatedModel.$newInstance(relatedModel.$toJson(), { operation: void 0 });
678
- relatedModelCopy.$setRelation("pivot", pivot);
678
+ relatedModelCopy.$setRelation(this.pivotKey, pivot, true);
679
679
  relationResults.push(relatedModelCopy);
680
680
  });
681
681
  parentModel.$setRelation(relation, relationResults);
682
+ parentModel.$setRelation(this.pivotKey, void 0);
682
683
  });
683
684
  }
684
685
  /**
@@ -686,6 +687,13 @@ class BelongsToMany extends Relation {
686
687
  */
687
688
  addEagerConstraints(_query, _collection) {
688
689
  }
690
+ /**
691
+ * Specify the custom pivot accessor to use for the relationship.
692
+ */
693
+ as(accessor) {
694
+ this.pivotKey = accessor;
695
+ return this;
696
+ }
689
697
  }
690
698
 
691
699
  var __defProp$d = Object.defineProperty;
@@ -2810,7 +2818,7 @@ class MorphToMany extends Relation {
2810
2818
  * Attach the parent type and id to the given relation.
2811
2819
  */
2812
2820
  attach(record, child) {
2813
- const pivot = child.pivot ?? {};
2821
+ const pivot = child[this.pivotKey] ?? {};
2814
2822
  pivot[this.morphId] = record[this.parentKey];
2815
2823
  pivot[this.morphType] = this.parent.$entity();
2816
2824
  pivot[this.relatedId] = child[this.relatedKey];
@@ -2833,7 +2841,7 @@ class MorphToMany extends Relation {
2833
2841
  relatedModels.forEach((relatedModel) => {
2834
2842
  const pivot = pivotModels[`[${parentModel[this.parentKey]},${relatedModel[this.relatedKey]},${this.parent.$entity()}]`]?.[0] ?? null;
2835
2843
  const relatedModelCopy = relatedModel.$newInstance(relatedModel.$toJson(), { operation: void 0 });
2836
- relatedModelCopy.$setRelation("pivot", pivot);
2844
+ relatedModelCopy.$setRelation(this.pivotKey, pivot, true);
2837
2845
  if (pivot) {
2838
2846
  relationResults.push(relatedModelCopy);
2839
2847
  }
@@ -2846,6 +2854,13 @@ class MorphToMany extends Relation {
2846
2854
  */
2847
2855
  addEagerConstraints(_query, _collection) {
2848
2856
  }
2857
+ /**
2858
+ * Specify the custom pivot accessor to use for the relationship.
2859
+ */
2860
+ as(accessor) {
2861
+ this.pivotKey = accessor;
2862
+ return this;
2863
+ }
2849
2864
  }
2850
2865
 
2851
2866
  var __defProp$1 = Object.defineProperty;
@@ -2911,7 +2926,7 @@ class MorphedByMany extends Relation {
2911
2926
  * Attach the parent type and id to the given relation.
2912
2927
  */
2913
2928
  attach(record, child) {
2914
- const pivot = record.pivot ?? {};
2929
+ const pivot = record[this.pivotKey] ?? {};
2915
2930
  pivot[this.morphId] = child[this.relatedKey];
2916
2931
  pivot[this.morphType] = this.related.$entity();
2917
2932
  pivot[this.relatedId] = record[this.parentKey];
@@ -2930,18 +2945,13 @@ class MorphedByMany extends Relation {
2930
2945
  const relatedModels = query.get(false);
2931
2946
  const pivotModels = query.newQuery(this.pivot.$modelEntity()).whereIn(this.relatedId, this.getKeys(models, this.parentKey)).whereIn(this.morphId, this.getKeys(relatedModels, this.relatedKey)).groupBy(this.relatedId, this.morphType).get();
2932
2947
  models.forEach((parentModel) => {
2933
- const relationResults = [];
2934
2948
  const resultModelIds = this.getKeys(pivotModels[`[${parentModel[this.parentKey]},${this.related.$entity()}]`] ?? [], this.morphId);
2935
2949
  const relatedModelsFiltered = relatedModels.filter((filterdModel) => resultModelIds.includes(filterdModel[this.relatedKey]));
2936
- relatedModelsFiltered.forEach((relatedModel) => {
2937
- const pivot = (pivotModels[`[${parentModel[this.parentKey]},${this.related.$entity()}]`] ?? []).find((pivotModel) => pivotModel[this.morphId] === relatedModel[this.relatedKey]) ?? null;
2938
- const relatedModelCopy = relatedModel.$newInstance(relatedModel.$toJson(), { operation: void 0 });
2939
- if (pivot) {
2940
- relatedModelCopy.$setRelation("pivot", pivot);
2941
- }
2942
- relationResults.push(relatedModelCopy);
2943
- });
2944
- parentModel.$setRelation(relation, relationResults);
2950
+ const pivot = (pivotModels[`[${parentModel[this.parentKey]},${this.related.$entity()}]`] ?? [])?.[0] ?? null;
2951
+ if (pivot) {
2952
+ parentModel.$setRelation(this.pivotKey, pivot, true);
2953
+ }
2954
+ parentModel.$setRelation(relation, relatedModelsFiltered);
2945
2955
  });
2946
2956
  }
2947
2957
  /**
@@ -2949,6 +2959,13 @@ class MorphedByMany extends Relation {
2949
2959
  */
2950
2960
  addEagerConstraints(_query, _collection) {
2951
2961
  }
2962
+ /**
2963
+ * Specify the custom pivot accessor to use for the relationship.
2964
+ */
2965
+ as(accessor) {
2966
+ this.pivotKey = accessor;
2967
+ return this;
2968
+ }
2952
2969
  }
2953
2970
 
2954
2971
  var __defProp = Object.defineProperty;
@@ -2962,8 +2979,6 @@ class Model {
2962
2979
  * Create a new model instance.
2963
2980
  */
2964
2981
  constructor(attributes, options = { operation: "set" }) {
2965
- // [s: keyof ModelFields]: any
2966
- __publicField(this, "pivot");
2967
2982
  this.$boot();
2968
2983
  const fill = options.fill ?? true;
2969
2984
  fill && this.$fill(attributes, options);
@@ -3535,12 +3550,8 @@ class Model {
3535
3550
  /**
3536
3551
  * Set the given relationship on the model.
3537
3552
  */
3538
- $setRelation(relation, model) {
3539
- if (relation.includes("pivot")) {
3540
- this.pivot = model;
3541
- return this;
3542
- }
3543
- if (this.$fields()[relation]) {
3553
+ $setRelation(relation, model, isPivot = false) {
3554
+ if (this.$fields()[relation] || isPivot) {
3544
3555
  this[relation] = model;
3545
3556
  }
3546
3557
  return this;
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.cjs';
1
+ import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.cjs';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.mjs';
1
+ import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.mjs';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.js';
1
+ import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.js';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.cjs';
1
+ import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.cjs';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.mjs';
1
+ import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.mjs';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.js';
1
+ import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.js';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.cjs';
1
+ import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.cjs';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.mjs';
1
+ import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.mjs';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
@@ -1,4 +1,4 @@
1
- import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.js';
1
+ import { a0 as CastAttribute, aq as NanoidOptions, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.js';
2
2
  import 'pinia';
3
3
  import '@/composables';
4
4
  import '@pinia-orm/normalizr';
@@ -888,6 +888,10 @@ declare class BelongsToMany extends Relation {
888
888
  * Set the constraints for the related relation.
889
889
  */
890
890
  addEagerConstraints(_query: Query, _collection: Collection): void;
891
+ /**
892
+ * Specify the custom pivot accessor to use for the relationship.
893
+ */
894
+ as(accessor: string): this;
891
895
  }
892
896
 
893
897
  declare class HasMany extends Relation {
@@ -1317,6 +1321,10 @@ declare class MorphToMany extends Relation {
1317
1321
  * Set the constraints for the related relation.
1318
1322
  */
1319
1323
  addEagerConstraints(_query: Query, _collection: Collection): void;
1324
+ /**
1325
+ * Specify the custom pivot accessor to use for the relationship.
1326
+ */
1327
+ as(accessor: string): this;
1320
1328
  }
1321
1329
 
1322
1330
  type ModelFields = Record<string, Attribute>;
@@ -1350,7 +1358,6 @@ type WithKeys<T> = {
1350
1358
  [P in keyof T]: T[P] extends (Model | null) | Model[] ? P & string : never;
1351
1359
  }[keyof T];
1352
1360
  declare class Model {
1353
- pivot?: any;
1354
1361
  _meta: undefined | MetaValues;
1355
1362
  /**
1356
1363
  * The name of the model.
@@ -1721,7 +1728,7 @@ declare class Model {
1721
1728
  /**
1722
1729
  * Set the given relationship on the model.
1723
1730
  */
1724
- $setRelation(relation: string, model: Model | Model[] | null): this;
1731
+ $setRelation(relation: string, model: Model | Model[] | null, isPivot?: boolean): this;
1725
1732
  /**
1726
1733
  * Get the mutators of the model
1727
1734
  */
@@ -888,6 +888,10 @@ declare class BelongsToMany extends Relation {
888
888
  * Set the constraints for the related relation.
889
889
  */
890
890
  addEagerConstraints(_query: Query, _collection: Collection): void;
891
+ /**
892
+ * Specify the custom pivot accessor to use for the relationship.
893
+ */
894
+ as(accessor: string): this;
891
895
  }
892
896
 
893
897
  declare class HasMany extends Relation {
@@ -1317,6 +1321,10 @@ declare class MorphToMany extends Relation {
1317
1321
  * Set the constraints for the related relation.
1318
1322
  */
1319
1323
  addEagerConstraints(_query: Query, _collection: Collection): void;
1324
+ /**
1325
+ * Specify the custom pivot accessor to use for the relationship.
1326
+ */
1327
+ as(accessor: string): this;
1320
1328
  }
1321
1329
 
1322
1330
  type ModelFields = Record<string, Attribute>;
@@ -1350,7 +1358,6 @@ type WithKeys<T> = {
1350
1358
  [P in keyof T]: T[P] extends (Model | null) | Model[] ? P & string : never;
1351
1359
  }[keyof T];
1352
1360
  declare class Model {
1353
- pivot?: any;
1354
1361
  _meta: undefined | MetaValues;
1355
1362
  /**
1356
1363
  * The name of the model.
@@ -1721,7 +1728,7 @@ declare class Model {
1721
1728
  /**
1722
1729
  * Set the given relationship on the model.
1723
1730
  */
1724
- $setRelation(relation: string, model: Model | Model[] | null): this;
1731
+ $setRelation(relation: string, model: Model | Model[] | null, isPivot?: boolean): this;
1725
1732
  /**
1726
1733
  * Get the mutators of the model
1727
1734
  */
@@ -888,6 +888,10 @@ declare class BelongsToMany extends Relation {
888
888
  * Set the constraints for the related relation.
889
889
  */
890
890
  addEagerConstraints(_query: Query, _collection: Collection): void;
891
+ /**
892
+ * Specify the custom pivot accessor to use for the relationship.
893
+ */
894
+ as(accessor: string): this;
891
895
  }
892
896
 
893
897
  declare class HasMany extends Relation {
@@ -1317,6 +1321,10 @@ declare class MorphToMany extends Relation {
1317
1321
  * Set the constraints for the related relation.
1318
1322
  */
1319
1323
  addEagerConstraints(_query: Query, _collection: Collection): void;
1324
+ /**
1325
+ * Specify the custom pivot accessor to use for the relationship.
1326
+ */
1327
+ as(accessor: string): this;
1320
1328
  }
1321
1329
 
1322
1330
  type ModelFields = Record<string, Attribute>;
@@ -1350,7 +1358,6 @@ type WithKeys<T> = {
1350
1358
  [P in keyof T]: T[P] extends (Model | null) | Model[] ? P & string : never;
1351
1359
  }[keyof T];
1352
1360
  declare class Model {
1353
- pivot?: any;
1354
1361
  _meta: undefined | MetaValues;
1355
1362
  /**
1356
1363
  * The name of the model.
@@ -1721,7 +1728,7 @@ declare class Model {
1721
1728
  /**
1722
1729
  * Set the given relationship on the model.
1723
1730
  */
1724
- $setRelation(relation: string, model: Model | Model[] | null): this;
1731
+ $setRelation(relation: string, model: Model | Model[] | null, isPivot?: boolean): this;
1725
1732
  /**
1726
1733
  * Get the mutators of the model
1727
1734
  */
@@ -1,5 +1,5 @@
1
1
  import { V1Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.cjs';
2
+ import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.cjs';
3
3
  import 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
@@ -1,5 +1,5 @@
1
1
  import { V1Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.mjs';
2
+ import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.mjs';
3
3
  import 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
package/dist/uuid/v1.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { V1Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.js';
2
+ import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.js';
3
3
  import 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
@@ -1,5 +1,5 @@
1
1
  import { V4Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.cjs';
2
+ import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.cjs';
3
3
  import 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
@@ -1,5 +1,5 @@
1
1
  import { V4Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.mjs';
2
+ import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.mjs';
3
3
  import 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
package/dist/uuid/v4.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { V4Options } from 'uuid';
2
- import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.e4d337f9.js';
2
+ import { a0 as CastAttribute, m as ModelFields, an as PropertyDecorator } from '../shared/pinia-orm.90cdba8c.js';
3
3
  import 'pinia';
4
4
  import '@/composables';
5
5
  import '@pinia-orm/normalizr';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinia-orm-edge",
3
- "version": "1.10.0-28693042.c6e88ef",
3
+ "version": "1.10.0-28693841.a86c2d9",
4
4
  "description": "The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.",
5
5
  "keywords": [
6
6
  "vue",
@@ -46,7 +46,7 @@
46
46
  "pinia": "^2.1.7"
47
47
  },
48
48
  "dependencies": {
49
- "@pinia-orm/normalizr": "npm:@pinia-orm/normalizr-edge@1.10.0-28693042.c6e88ef"
49
+ "@pinia-orm/normalizr": "npm:@pinia-orm/normalizr-edge@1.10.0-28693841.a86c2d9"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@nuxt/eslint-config": "^0.3.13",