@bunyad/orm 0.1.0-alpha.0 → 0.2.0-beta.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.
- package/README.md +3 -3
- package/dist/concerns.d.ts +2 -2
- package/dist/factory.d.ts +3 -3
- package/dist/model-events.d.ts +2 -2
- package/dist/model-events.js +1 -1
- package/dist/model-query.d.ts +55 -55
- package/dist/model-query.js +51 -51
- package/dist/model-strictness.d.ts +2 -3
- package/dist/model-strictness.js +2 -3
- package/dist/model.d.ts +106 -106
- package/dist/model.js +103 -103
- package/dist/orm-collection.d.ts +1 -1
- package/dist/orm-collection.js +1 -1
- package/dist/relations.d.ts +4 -4
- package/dist/relations.js +3 -3
- package/dist/scopes.d.ts +1 -2
- package/dist/scopes.js +1 -2
- package/package.json +3 -3
package/dist/orm-collection.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class OrmCollection<T extends Model = Model> extends Collection<T
|
|
|
18
18
|
* Load only relations that are not already present (`loadMissing`).
|
|
19
19
|
*/
|
|
20
20
|
loadMissing(...relations: Array<string | Record<string, unknown>>): Promise<this>;
|
|
21
|
-
/**
|
|
21
|
+
/** `$collection->loadCount(...)` — batched GROUP BY per relation. */
|
|
22
22
|
loadCount(...relations: string[]): Promise<this>;
|
|
23
23
|
loadSum(relation: string, column: string): Promise<this>;
|
|
24
24
|
loadAvg(relation: string, column: string): Promise<this>;
|
package/dist/orm-collection.js
CHANGED
|
@@ -45,7 +45,7 @@ export class OrmCollection extends Collection {
|
|
|
45
45
|
await eagerLoadModels(this.all(), missing);
|
|
46
46
|
return this;
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
48
|
+
/** `$collection->loadCount(...)` — batched GROUP BY per relation. */
|
|
49
49
|
async loadCount(...relations) {
|
|
50
50
|
return this.#loadAggregates(relations.flat().map((raw) => {
|
|
51
51
|
const parsed = parseRelationAlias(raw);
|
package/dist/relations.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare class MorphOne<T extends Model = Model> {
|
|
|
65
65
|
first(): Promise<T | null>;
|
|
66
66
|
create(attributes: Record<string, unknown>): Promise<T>;
|
|
67
67
|
}
|
|
68
|
-
/**
|
|
68
|
+
/** MorphTo relation. */
|
|
69
69
|
export declare class MorphTo {
|
|
70
70
|
private parent;
|
|
71
71
|
private typeColumn;
|
|
@@ -77,9 +77,9 @@ export declare class MorphTo {
|
|
|
77
77
|
getOwnerKeyName(): string | undefined;
|
|
78
78
|
get(): Promise<Model | null>;
|
|
79
79
|
first(): Promise<Model | null>;
|
|
80
|
-
/**
|
|
80
|
+
/** `associate` for morphTo. */
|
|
81
81
|
associate(model: Model): this;
|
|
82
|
-
/**
|
|
82
|
+
/** `dissociate` for morphTo. */
|
|
83
83
|
dissociate(): this;
|
|
84
84
|
}
|
|
85
85
|
/** HasMany relation. */
|
|
@@ -220,7 +220,7 @@ export declare class BelongsToMany<T extends Model = Model> {
|
|
|
220
220
|
/** Attach missing, detach present. */
|
|
221
221
|
toggle(ids: Array<string | number> | string | number): Promise<void>;
|
|
222
222
|
}
|
|
223
|
-
/** Options for `morphToMany` beyond the
|
|
223
|
+
/** Options for `morphToMany` beyond the positional args. */
|
|
224
224
|
export type MorphToManyOptions = {
|
|
225
225
|
table?: string;
|
|
226
226
|
foreignPivotKey?: string;
|
package/dist/relations.js
CHANGED
|
@@ -299,7 +299,7 @@ export class MorphOne {
|
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
|
-
/**
|
|
302
|
+
/** MorphTo relation. */
|
|
303
303
|
export class MorphTo {
|
|
304
304
|
parent;
|
|
305
305
|
typeColumn;
|
|
@@ -335,7 +335,7 @@ export class MorphTo {
|
|
|
335
335
|
}
|
|
336
336
|
return Related.find(id);
|
|
337
337
|
}
|
|
338
|
-
/**
|
|
338
|
+
/** `associate` for morphTo. */
|
|
339
339
|
associate(model) {
|
|
340
340
|
const row = this.parent;
|
|
341
341
|
const Related = model.constructor;
|
|
@@ -344,7 +344,7 @@ export class MorphTo {
|
|
|
344
344
|
row[this.idColumn] = model[key];
|
|
345
345
|
return this;
|
|
346
346
|
}
|
|
347
|
-
/**
|
|
347
|
+
/** `dissociate` for morphTo. */
|
|
348
348
|
dissociate() {
|
|
349
349
|
const row = this.parent;
|
|
350
350
|
row[this.typeColumn] = null;
|
package/dist/scopes.d.ts
CHANGED
|
@@ -21,11 +21,10 @@ type CallStaticModel = {
|
|
|
21
21
|
* Model statics, and arbitrary junk. Own Model / subclass statics always win
|
|
22
22
|
* over this Proxy. Local `scopeFoo` still wins when present.
|
|
23
23
|
*
|
|
24
|
-
* @see https://laravel.com/docs/eloquent#retrieving-models
|
|
25
24
|
*/
|
|
26
25
|
export declare const MODEL_STATIC_BUILDER_TERMINALS: ReadonlySet<string>;
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
27
|
+
* `__callStatic`:
|
|
29
28
|
* - Local scopes: `Model.foo()` → `Model.query().foo()` when `scopeFoo` exists
|
|
30
29
|
* - Builder terminals: `Model.get()` / `pluck` / `count` / … → `Model.query()[method](…)`
|
|
31
30
|
*
|
package/dist/scopes.js
CHANGED
|
@@ -39,7 +39,6 @@ export function clearGlobalScopes(model) {
|
|
|
39
39
|
* Model statics, and arbitrary junk. Own Model / subclass statics always win
|
|
40
40
|
* over this Proxy. Local `scopeFoo` still wins when present.
|
|
41
41
|
*
|
|
42
|
-
* @see https://laravel.com/docs/eloquent#retrieving-models
|
|
43
42
|
*/
|
|
44
43
|
export const MODEL_STATIC_BUILDER_TERMINALS = new Set([
|
|
45
44
|
"get",
|
|
@@ -67,7 +66,7 @@ export const MODEL_STATIC_BUILDER_TERMINALS = new Set([
|
|
|
67
66
|
"getBindings",
|
|
68
67
|
]);
|
|
69
68
|
/**
|
|
70
|
-
*
|
|
69
|
+
* `__callStatic`:
|
|
71
70
|
* - Local scopes: `Model.foo()` → `Model.query().foo()` when `scopeFoo` exists
|
|
72
71
|
* - Builder terminals: `Model.get()` / `pluck` / `count` / … → `Model.query()[method](…)`
|
|
73
72
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bunyad/orm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-beta.0",
|
|
4
4
|
"description": "Active-record ORM for Bunyad: models, relations, casts, scopes, events, factories.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Shah Khalid",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@bunyad/common": "^0.
|
|
40
|
-
"@bunyad/database": "^0.
|
|
39
|
+
"@bunyad/common": "^0.2.0-beta.0",
|
|
40
|
+
"@bunyad/database": "^0.2.0-beta.0"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|