metal-orm 1.0.105 → 1.0.107
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/index.cjs +136 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +136 -130
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/orm/entity-relations.ts +7 -30
- package/src/orm/entity.ts +10 -17
- package/src/orm/relations/belongs-to.ts +28 -19
- package/src/orm/relations/has-many.ts +35 -26
- package/src/orm/relations/has-one.ts +33 -24
- package/src/orm/relations/many-to-many.ts +33 -24
package/dist/index.d.cts
CHANGED
|
@@ -6463,7 +6463,6 @@ type Rows$2 = Record<string, unknown>[];
|
|
|
6463
6463
|
* @template TChild - The type of child entities in the collection
|
|
6464
6464
|
*/
|
|
6465
6465
|
declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChild> {
|
|
6466
|
-
#private;
|
|
6467
6466
|
private readonly ctx;
|
|
6468
6467
|
private readonly meta;
|
|
6469
6468
|
private readonly root;
|
|
@@ -6473,6 +6472,10 @@ declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChi
|
|
|
6473
6472
|
private readonly loader;
|
|
6474
6473
|
private readonly createEntity;
|
|
6475
6474
|
private readonly localKey;
|
|
6475
|
+
private loaded;
|
|
6476
|
+
private items;
|
|
6477
|
+
private readonly added;
|
|
6478
|
+
private readonly removed;
|
|
6476
6479
|
/**
|
|
6477
6480
|
* Creates a new DefaultHasManyCollection instance.
|
|
6478
6481
|
* @param ctx - The entity context
|
|
@@ -6524,7 +6527,6 @@ declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChi
|
|
|
6524
6527
|
* Clears all entities from the collection.
|
|
6525
6528
|
*/
|
|
6526
6529
|
clear(): void;
|
|
6527
|
-
isLoaded(): boolean;
|
|
6528
6530
|
private get relationKey();
|
|
6529
6531
|
private hydrateFromCache;
|
|
6530
6532
|
/**
|
|
@@ -6542,7 +6544,6 @@ type Rows$1 = Record<string, unknown>;
|
|
|
6542
6544
|
* @template TParent The type of the parent entity.
|
|
6543
6545
|
*/
|
|
6544
6546
|
declare class DefaultBelongsToReference<TParent extends object> implements BelongsToReferenceApi<TParent> {
|
|
6545
|
-
#private;
|
|
6546
6547
|
private readonly ctx;
|
|
6547
6548
|
private readonly meta;
|
|
6548
6549
|
private readonly root;
|
|
@@ -6552,6 +6553,8 @@ declare class DefaultBelongsToReference<TParent extends object> implements Belon
|
|
|
6552
6553
|
private readonly loader;
|
|
6553
6554
|
private readonly createEntity;
|
|
6554
6555
|
private readonly targetKey;
|
|
6556
|
+
private loaded;
|
|
6557
|
+
private current;
|
|
6555
6558
|
/**
|
|
6556
6559
|
* @param ctx The entity context for tracking changes.
|
|
6557
6560
|
* @param meta Metadata for the child entity.
|
|
@@ -6567,7 +6570,6 @@ declare class DefaultBelongsToReference<TParent extends object> implements Belon
|
|
|
6567
6570
|
load(): Promise<TParent | null>;
|
|
6568
6571
|
get(): TParent | null;
|
|
6569
6572
|
set(data: Partial<TParent> | TParent | null): TParent | null;
|
|
6570
|
-
isLoaded(): boolean;
|
|
6571
6573
|
private get relationKey();
|
|
6572
6574
|
private populateFromHydrationCache;
|
|
6573
6575
|
toJSON(): TParent | null;
|
|
@@ -6582,7 +6584,6 @@ type Rows = Record<string, unknown>[];
|
|
|
6582
6584
|
* @template TTarget The type of the target entities in the collection.
|
|
6583
6585
|
*/
|
|
6584
6586
|
declare class DefaultManyToManyCollection<TTarget, TPivot extends object | undefined = undefined> implements ManyToManyCollection<TTarget, TPivot> {
|
|
6585
|
-
#private;
|
|
6586
6587
|
private readonly ctx;
|
|
6587
6588
|
private readonly meta;
|
|
6588
6589
|
private readonly root;
|
|
@@ -6592,6 +6593,8 @@ declare class DefaultManyToManyCollection<TTarget, TPivot extends object | undef
|
|
|
6592
6593
|
private readonly loader;
|
|
6593
6594
|
private readonly createEntity;
|
|
6594
6595
|
private readonly localKey;
|
|
6596
|
+
private loaded;
|
|
6597
|
+
private items;
|
|
6595
6598
|
/**
|
|
6596
6599
|
* @param ctx The entity context for tracking changes.
|
|
6597
6600
|
* @param meta Metadata for the root entity.
|
|
@@ -6640,7 +6643,6 @@ declare class DefaultManyToManyCollection<TTarget, TPivot extends object | undef
|
|
|
6640
6643
|
* @param ids Array of primary key values to sync with.
|
|
6641
6644
|
*/
|
|
6642
6645
|
syncByIds(ids: (number | string)[]): Promise<void>;
|
|
6643
|
-
isLoaded(): boolean;
|
|
6644
6646
|
private ensureEntity;
|
|
6645
6647
|
private extractId;
|
|
6646
6648
|
private get relationKey();
|
package/dist/index.d.ts
CHANGED
|
@@ -6463,7 +6463,6 @@ type Rows$2 = Record<string, unknown>[];
|
|
|
6463
6463
|
* @template TChild - The type of child entities in the collection
|
|
6464
6464
|
*/
|
|
6465
6465
|
declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChild> {
|
|
6466
|
-
#private;
|
|
6467
6466
|
private readonly ctx;
|
|
6468
6467
|
private readonly meta;
|
|
6469
6468
|
private readonly root;
|
|
@@ -6473,6 +6472,10 @@ declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChi
|
|
|
6473
6472
|
private readonly loader;
|
|
6474
6473
|
private readonly createEntity;
|
|
6475
6474
|
private readonly localKey;
|
|
6475
|
+
private loaded;
|
|
6476
|
+
private items;
|
|
6477
|
+
private readonly added;
|
|
6478
|
+
private readonly removed;
|
|
6476
6479
|
/**
|
|
6477
6480
|
* Creates a new DefaultHasManyCollection instance.
|
|
6478
6481
|
* @param ctx - The entity context
|
|
@@ -6524,7 +6527,6 @@ declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChi
|
|
|
6524
6527
|
* Clears all entities from the collection.
|
|
6525
6528
|
*/
|
|
6526
6529
|
clear(): void;
|
|
6527
|
-
isLoaded(): boolean;
|
|
6528
6530
|
private get relationKey();
|
|
6529
6531
|
private hydrateFromCache;
|
|
6530
6532
|
/**
|
|
@@ -6542,7 +6544,6 @@ type Rows$1 = Record<string, unknown>;
|
|
|
6542
6544
|
* @template TParent The type of the parent entity.
|
|
6543
6545
|
*/
|
|
6544
6546
|
declare class DefaultBelongsToReference<TParent extends object> implements BelongsToReferenceApi<TParent> {
|
|
6545
|
-
#private;
|
|
6546
6547
|
private readonly ctx;
|
|
6547
6548
|
private readonly meta;
|
|
6548
6549
|
private readonly root;
|
|
@@ -6552,6 +6553,8 @@ declare class DefaultBelongsToReference<TParent extends object> implements Belon
|
|
|
6552
6553
|
private readonly loader;
|
|
6553
6554
|
private readonly createEntity;
|
|
6554
6555
|
private readonly targetKey;
|
|
6556
|
+
private loaded;
|
|
6557
|
+
private current;
|
|
6555
6558
|
/**
|
|
6556
6559
|
* @param ctx The entity context for tracking changes.
|
|
6557
6560
|
* @param meta Metadata for the child entity.
|
|
@@ -6567,7 +6570,6 @@ declare class DefaultBelongsToReference<TParent extends object> implements Belon
|
|
|
6567
6570
|
load(): Promise<TParent | null>;
|
|
6568
6571
|
get(): TParent | null;
|
|
6569
6572
|
set(data: Partial<TParent> | TParent | null): TParent | null;
|
|
6570
|
-
isLoaded(): boolean;
|
|
6571
6573
|
private get relationKey();
|
|
6572
6574
|
private populateFromHydrationCache;
|
|
6573
6575
|
toJSON(): TParent | null;
|
|
@@ -6582,7 +6584,6 @@ type Rows = Record<string, unknown>[];
|
|
|
6582
6584
|
* @template TTarget The type of the target entities in the collection.
|
|
6583
6585
|
*/
|
|
6584
6586
|
declare class DefaultManyToManyCollection<TTarget, TPivot extends object | undefined = undefined> implements ManyToManyCollection<TTarget, TPivot> {
|
|
6585
|
-
#private;
|
|
6586
6587
|
private readonly ctx;
|
|
6587
6588
|
private readonly meta;
|
|
6588
6589
|
private readonly root;
|
|
@@ -6592,6 +6593,8 @@ declare class DefaultManyToManyCollection<TTarget, TPivot extends object | undef
|
|
|
6592
6593
|
private readonly loader;
|
|
6593
6594
|
private readonly createEntity;
|
|
6594
6595
|
private readonly localKey;
|
|
6596
|
+
private loaded;
|
|
6597
|
+
private items;
|
|
6595
6598
|
/**
|
|
6596
6599
|
* @param ctx The entity context for tracking changes.
|
|
6597
6600
|
* @param meta Metadata for the root entity.
|
|
@@ -6640,7 +6643,6 @@ declare class DefaultManyToManyCollection<TTarget, TPivot extends object | undef
|
|
|
6640
6643
|
* @param ids Array of primary key values to sync with.
|
|
6641
6644
|
*/
|
|
6642
6645
|
syncByIds(ids: (number | string)[]): Promise<void>;
|
|
6643
|
-
isLoaded(): boolean;
|
|
6644
6646
|
private ensureEntity;
|
|
6645
6647
|
private extractId;
|
|
6646
6648
|
private get relationKey();
|