@bunyad/orm 0.1.0-alpha.0 → 0.2.0-beta.1

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/model.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Connection, DatabaseManager, DateInput } from "@bunyad/database";
2
2
  import { LengthAwarePaginator, CursorPaginator } from "@bunyad/database";
3
- import { Collection } from "@bunyad/common";
3
+ import { Collection, LazyCollection } from "@bunyad/common";
4
4
  import { OrmCollection } from "./orm-collection.js";
5
5
  import { type CastDefinition } from "./casts.js";
6
6
  import { type ModelEventListener, type ModelEventName, type ModelObserver } from "./model-events.js";
@@ -81,7 +81,7 @@ export declare class Model {
81
81
  /** When false, `save()` skips `created_at` / `updated_at`. */
82
82
  static timestamps: boolean;
83
83
  /**
84
- * Laravel `$casts` property — prefer `static casts()` when adding enums / Attribute.
84
+ * `$casts` property — prefer `static casts()` when adding enums / Attribute.
85
85
  * May be a plain object or a method returning the map.
86
86
  */
87
87
  static casts: Record<string, CastDefinition> | (() => Record<string, CastDefinition>);
@@ -92,22 +92,22 @@ export declare class Model {
92
92
  */
93
93
  static relations: RelationsMap;
94
94
  /**
95
- * Laravel `$touches` — relation names whose related models get `touch()` after
95
+ * `$touches` — relation names whose related models get `touch()` after
96
96
  * this model is saved (or soft-deleted). Honor `withoutTouching`.
97
97
  */
98
98
  static touches: string[];
99
- /** Laravel `$hidden`. */
99
+ /** `$hidden`. */
100
100
  static hidden: string[];
101
- /** Laravel `$visible` allow-list (empty = all non-hidden). */
101
+ /** `$visible` allow-list (empty = all non-hidden). */
102
102
  static visible: string[];
103
- /** Laravel `$appends` — accessors included in `toArray()`. */
103
+ /** `$appends` — accessors included in `toArray()`. */
104
104
  static appends: string[];
105
- /** Laravel `$fillable`. */
105
+ /** `$fillable`. */
106
106
  static fillable: readonly string[] | string[];
107
- /** Laravel `$guarded` — default guard all until fillable is set. */
107
+ /** `$guarded` — default guard all until fillable is set. */
108
108
  static guarded: readonly string[] | string[];
109
109
  id: string | number;
110
- /** Laravel `$exists` — true after retrieve / successful insert. */
110
+ /** `$exists` — true after retrieve / successful insert. */
111
111
  get exists(): boolean;
112
112
  set exists(value: boolean);
113
113
  constructor(attributes?: Record<string, unknown>);
@@ -121,81 +121,81 @@ export declare class Model {
121
121
  /** Current attribute bag (non-function own properties). */
122
122
  getAttributes(): Record<string, unknown>;
123
123
  /**
124
- * Laravel `getAttribute` — throws when `preventAccessingMissingAttributes` is on
124
+ * `getAttribute` — throws when `preventAccessingMissingAttributes` is on
125
125
  * and the key was not retrieved / does not exist (relations exempt).
126
126
  */
127
127
  getAttribute(key: string): unknown;
128
- /** Laravel `isDirty`. */
128
+ /** `isDirty`. */
129
129
  isDirty(...attributes: string[]): boolean;
130
- /** Laravel `isClean`. */
130
+ /** `isClean`. */
131
131
  isClean(...attributes: string[]): boolean;
132
- /** Laravel `getDirty`. */
132
+ /** `getDirty`. */
133
133
  getDirty(): Record<string, unknown>;
134
- /** Laravel `getOriginal`. */
134
+ /** `getOriginal`. */
135
135
  getOriginal(): Record<string, unknown>;
136
136
  getOriginal(key: string): unknown;
137
- /** Laravel `getChanges` — attributes changed by the last save. */
137
+ /** `getChanges` — attributes changed by the last save. */
138
138
  getChanges(): Record<string, unknown>;
139
- /** Laravel `wasChanged`. */
139
+ /** `wasChanged`. */
140
140
  wasChanged(...attributes: string[]): boolean;
141
- /** Laravel `wasRecentlyCreated`. */
141
+ /** `wasRecentlyCreated`. */
142
142
  wasRecentlyCreated(): boolean;
143
- /** Laravel `append`. */
143
+ /** `append`. */
144
144
  append(...attributes: string[]): this;
145
- /** Laravel `setAppends`. */
145
+ /** `setAppends`. */
146
146
  setAppends(attributes: string[]): this;
147
- /** Laravel `getAppends`. */
147
+ /** `getAppends`. */
148
148
  getAppends(): string[];
149
- /** Laravel `getHidden`. */
149
+ /** `getHidden`. */
150
150
  getHidden(): string[];
151
- /** Laravel `getVisible`. */
151
+ /** `getVisible`. */
152
152
  getVisible(): string[];
153
- /** Laravel `setHidden`. */
153
+ /** `setHidden`. */
154
154
  setHidden(attributes: string[]): this;
155
- /** Laravel `setVisible`. */
155
+ /** `setVisible`. */
156
156
  setVisible(attributes: string[]): this;
157
- /** Laravel `makeVisible` — show attributes for this instance. */
157
+ /** `makeVisible` — show attributes for this instance. */
158
158
  makeVisible(...attributes: string[]): this;
159
- /** Laravel `makeHidden` — hide attributes for this instance. */
159
+ /** `makeHidden` — hide attributes for this instance. */
160
160
  makeHidden(...attributes: string[]): this;
161
161
  /**
162
- * Run a callback without touching timestamps (Laravel `Model::withoutTimestamps`).
162
+ * Run a callback without touching timestamps (`Model::withoutTimestamps`).
163
163
  */
164
164
  static withoutTimestamps<T>(this: typeof Model, callback: () => T | Promise<T>): Promise<T>;
165
165
  /**
166
- * Laravel `Model::withoutTouching` — skip parent `touch()` while callback runs.
166
+ * `Model::withoutTouching` — skip parent `touch()` while callback runs.
167
167
  * Pass model classes to limit which models ignore touch; omit for all.
168
168
  */
169
169
  static withoutTouching<T>(this: typeof Model, callback: () => T | Promise<T>): Promise<T>;
170
170
  static withoutTouching<T>(this: typeof Model, models: Array<typeof Model>, callback: () => T | Promise<T>): Promise<T>;
171
171
  /** Whether touch is currently suppressed for this model class. */
172
172
  static isIgnoringTouch(this: typeof Model): boolean;
173
- /** Laravel `Model::preventLazyLoading`. */
173
+ /** `Model::preventLazyLoading`. */
174
174
  static preventLazyLoading(prevent?: boolean): void;
175
- /** Laravel `Model::preventSilentlyDiscardingAttributes`. */
175
+ /** `Model::preventSilentlyDiscardingAttributes`. */
176
176
  static preventSilentlyDiscardingAttributes(prevent?: boolean): void;
177
- /** Laravel `Model::preventAccessingMissingAttributes`. */
177
+ /** `Model::preventAccessingMissingAttributes`. */
178
178
  static preventAccessingMissingAttributes(prevent?: boolean): void;
179
- /** Laravel `Model::shouldBeStrict` — enable/disable the strictness trio. */
179
+ /** `Model::shouldBeStrict` — enable/disable the strictness trio. */
180
180
  static shouldBeStrict(should?: boolean): void;
181
- /** Laravel `Model::addGlobalScope`. */
181
+ /** `Model::addGlobalScope`. */
182
182
  static addGlobalScope(this: typeof Model, nameOrScope: string | GlobalScopeCallback, scope?: GlobalScopeCallback): void;
183
- /** Laravel `Model::addGlobalScope` removal helper. */
183
+ /** `Model::addGlobalScope` removal helper. */
184
184
  static removeGlobalScope(this: typeof Model, name: string): void;
185
185
  /**
186
- * Laravel `boot` — runs once per model class before first use.
186
+ * `boot` — runs once per model class before first use.
187
187
  * Prefer registering listeners in `booted()`.
188
188
  */
189
189
  static boot(): void;
190
190
  /**
191
- * Laravel `booted` — runs once after `boot`. Typical place for `static::created(...)`.
191
+ * `booted` — runs once after `boot`. Typical place for `static::created(...)`.
192
192
  */
193
193
  static booted(): void;
194
194
  /** Ensure this model class has been booted. */
195
195
  static bootIfNotBooted(): void;
196
- /** Laravel `Model::observe`. */
196
+ /** `Model::observe`. */
197
197
  static observe<T extends Model>(this: abstract new (...args: never[]) => T, observer: ModelObserver<T> | (new () => ModelObserver<T>) | Array<ModelObserver<T> | (new () => ModelObserver<T>)>): void;
198
- /** Laravel `Model::withoutEvents`. */
198
+ /** `Model::withoutEvents`. */
199
199
  static withoutEvents<T>(this: typeof Model, callback: () => T | Promise<T>): T | Promise<T>;
200
200
  static retrieved(callback: ModelEventListener): void;
201
201
  static creating(callback: ModelEventListener): void;
@@ -219,13 +219,13 @@ export declare class Model {
219
219
  static castAttributes(attributes: Record<string, unknown>, direction: "get" | "set"): Record<string, unknown>;
220
220
  static setConnection(connection: Connection): void;
221
221
  static getConnection(): Connection;
222
- /** Laravel `$model->setConnection($name)`. */
222
+ /** `$model->setConnection($name)`. */
223
223
  setConnection(connection: string | Connection): this;
224
224
  /** Active connection for this instance (instance override → model → default). */
225
225
  getConnection(): Connection;
226
226
  static db(): DatabaseManager;
227
227
  /**
228
- * Laravel `Model::on($connection)` — same model, different named connection.
228
+ * `Model::on($connection)` — same model, different named connection.
229
229
  */
230
230
  static on<T extends typeof Model>(this: T, connection: string): ModelQuery<InstanceType<T>>;
231
231
  /**
@@ -233,37 +233,37 @@ export declare class Model {
233
233
  * Local scopes (`scopeActive` → `.active()`) are available via proxy.
234
234
  */
235
235
  static newQuery<T extends typeof Model>(this: T, options?: ModelQueryOptions): ModelQuery<InstanceType<T>>;
236
- /** Laravel `withoutGlobalScopes()`. */
236
+ /** `withoutGlobalScopes()`. */
237
237
  static withoutGlobalScopes<T extends typeof Model>(this: T, names?: string[]): ModelQuery<InstanceType<T>>;
238
- /** Laravel `withoutGlobalScope($name)`. */
238
+ /** `withoutGlobalScope($name)`. */
239
239
  static withoutGlobalScope<T extends typeof Model>(this: T, name: string): ModelQuery<InstanceType<T>>;
240
- /** Laravel `Model::query()` — scoped `ModelQuery` (not a raw table builder). */
240
+ /** `Model::query()` — scoped `ModelQuery` (not a raw table builder). */
241
241
  static query<T extends typeof Model>(this: T, options?: ModelQueryOptions): ModelQuery<InstanceType<T>>;
242
- /** Laravel `Model::find`. */
242
+ /** `Model::find`. */
243
243
  static find<T extends typeof Model>(this: T, id: string | number): InstanceType<T> | null | Promise<InstanceType<T> | null>;
244
- /** Laravel `getRouteKeyName()` — column used for implicit route binding. */
244
+ /** `getRouteKeyName()` — column used for implicit route binding. */
245
245
  static getRouteKeyName(): string;
246
246
  /**
247
- * Laravel `resolveRouteBinding` — find by PK or custom `{param:column}` field.
247
+ * `resolveRouteBinding` — find by PK or custom `{param:column}` field.
248
248
  */
249
249
  static resolveRouteBinding<T extends typeof Model>(this: T, value: string | number, field?: string): InstanceType<T> | null | Promise<InstanceType<T> | null>;
250
250
  /**
251
- * Laravel SoftDeletes `resolveSoftDeletableRouteBinding` — same as
251
+ * `resolveSoftDeletableRouteBinding` — same as
252
252
  * `resolveRouteBinding` but includes soft-deleted rows (`withTrashed()`).
253
253
  * Used by the router when the route opts in via `withTrashed()`.
254
254
  */
255
255
  static resolveSoftDeletableRouteBinding<T extends typeof Model>(this: T, value: string | number, field?: string): InstanceType<T> | null | Promise<InstanceType<T> | null>;
256
- /** Laravel `Model::findOrFail`. */
256
+ /** `Model::findOrFail`. */
257
257
  static findOrFail<T extends typeof Model>(this: T, id: string | number): Promise<InstanceType<T>>;
258
- /** Laravel `Model::all`. */
258
+ /** `Model::all`. */
259
259
  static all<T extends typeof Model>(this: T): Promise<OrmCollection<InstanceType<T>>>;
260
260
  /**
261
- * Laravel `Model::get` — same as `query().get()` / `all()`.
261
+ * `Model::get` — same as `query().get()` / `all()`.
262
262
  * Typed helper for autocomplete; Proxy also forwards other terminals.
263
263
  */
264
264
  static get<T extends typeof Model>(this: T): OrmCollection<InstanceType<T>> | Promise<OrmCollection<InstanceType<T>>>;
265
265
  /**
266
- * Laravel `Model::pluck($column, $key = null)`.
266
+ * `Model::pluck($column, $key = null)`.
267
267
  * One column → list Collection; with `key` → keyed Record (see Collection.pluck).
268
268
  */
269
269
  static pluck<T extends typeof Model>(this: T, column: string): Promise<Collection<unknown>>;
@@ -272,13 +272,13 @@ export declare class Model {
272
272
  static allSync<T extends typeof Model>(this: T): OrmCollection<InstanceType<T>>;
273
273
  /** SQLite-only sync `find` — see `ModelQuery.firstSync`. */
274
274
  static findSync<T extends typeof Model>(this: T, id: string | number): InstanceType<T> | null;
275
- /** Laravel `Model::where`. */
275
+ /** `Model::where`. */
276
276
  static where<T extends typeof Model>(this: T, callback: (query: ModelQuery<InstanceType<T>>) => void): ModelQuery<InstanceType<T>>;
277
277
  static where<T extends typeof Model>(this: T, column: string, value: unknown): ModelQuery<InstanceType<T>>;
278
278
  static where<T extends typeof Model>(this: T, column: string, op: string, value: unknown): ModelQuery<InstanceType<T>>;
279
279
  /** Karobar-style multi-column LIKE search. */
280
280
  static search<T extends typeof Model>(this: T, columns: string[], term: string): ModelQuery<InstanceType<T>>;
281
- /** Start a new query and forward common builder methods (Laravel `__callStatic`). */
281
+ /** Start a new query and forward common builder methods (`__callStatic`). */
282
282
  static orWhere<T extends typeof Model>(this: T, column: string, value: unknown): ModelQuery<InstanceType<T>>;
283
283
  static orWhere<T extends typeof Model>(this: T, column: string, op: string, value: unknown): ModelQuery<InstanceType<T>>;
284
284
  static whereIn<T extends typeof Model>(this: T, column: string, values: unknown[]): ModelQuery<InstanceType<T>>;
@@ -294,36 +294,36 @@ export declare class Model {
294
294
  static limit<T extends typeof Model>(this: T, value: number): ModelQuery<InstanceType<T>>;
295
295
  static take<T extends typeof Model>(this: T, value: number): ModelQuery<InstanceType<T>>;
296
296
  static select<T extends typeof Model>(this: T, ...columns: string[]): ModelQuery<InstanceType<T>>;
297
- /** Laravel `Model::whereDate`. */
297
+ /** `Model::whereDate`. */
298
298
  static whereDate<T extends typeof Model>(this: T, column: string, value: DateInput): ModelQuery<InstanceType<T>>;
299
299
  static whereDate<T extends typeof Model>(this: T, column: string, op: string, value: DateInput): ModelQuery<InstanceType<T>>;
300
- /** Laravel `Model::whereNot(closure)`. */
300
+ /** `Model::whereNot(closure)`. */
301
301
  static whereNot<T extends typeof Model>(this: T, callback: (query: ModelQuery<InstanceType<T>>) => void): ModelQuery<InstanceType<T>>;
302
- /** Laravel `Model::orWhereNot(closure)`. */
302
+ /** `Model::orWhereNot(closure)`. */
303
303
  static orWhereNot<T extends typeof Model>(this: T, callback: (query: ModelQuery<InstanceType<T>>) => void): ModelQuery<InstanceType<T>>;
304
- /** Laravel `withTrashed()`. */
304
+ /** `withTrashed()`. */
305
305
  static withTrashed<T extends typeof Model>(this: T): ModelQuery<InstanceType<T>>;
306
- /** Laravel `onlyTrashed()`. */
306
+ /** `onlyTrashed()`. */
307
307
  static onlyTrashed<T extends typeof Model>(this: T): ModelQuery<InstanceType<T>>;
308
- /** Laravel `withoutTrashed()`. */
308
+ /** `withoutTrashed()`. */
309
309
  static withoutTrashed<T extends typeof Model>(this: T): ModelQuery<InstanceType<T>>;
310
310
  /** `get()` returns plain row objects. Models are not built. */
311
311
  static rows<T extends typeof Model>(this: T): ModelQuery<InstanceType<T>, "row">;
312
312
  /** Eager-load relations (`with('posts')`, `with({ posts: (q) => q.where(…) })`). */
313
313
  static with<T extends typeof Model>(this: T, ...relations: Array<string | string[] | Record<string, unknown>>): ModelQuery<InstanceType<T>>;
314
- /** Laravel `Model::whereHas`. */
314
+ /** `Model::whereHas`. */
315
315
  static whereHas<T extends typeof Model>(this: T, relation: string, callback?: (query: ModelQuery) => void): ModelQuery<InstanceType<T>>;
316
- /** Laravel `Model::whereDoesntHave`. */
316
+ /** `Model::whereDoesntHave`. */
317
317
  static whereDoesntHave<T extends typeof Model>(this: T, relation: string, callback?: (query: ModelQuery) => void): ModelQuery<InstanceType<T>>;
318
- /** Laravel `Model::orWhereHas`. */
318
+ /** `Model::orWhereHas`. */
319
319
  static orWhereHas<T extends typeof Model>(this: T, relation: string, callback?: (query: ModelQuery) => void): ModelQuery<InstanceType<T>>;
320
- /** Laravel `Model::whereRelation`. */
320
+ /** `Model::whereRelation`. */
321
321
  static whereRelation<T extends typeof Model>(this: T, relation: string, column: string, opOrValue: unknown, value?: unknown): ModelQuery<InstanceType<T>>;
322
- /** Laravel `Model::orWhereRelation`. */
322
+ /** `Model::orWhereRelation`. */
323
323
  static orWhereRelation<T extends typeof Model>(this: T, relation: string, column: string, opOrValue: unknown, value?: unknown): ModelQuery<InstanceType<T>>;
324
324
  /** `withCount` — `'posts'`, `'posts as post_total'`, a string list, or `{ products: { as: 'productsCount' } }`. */
325
325
  static withCount<T extends typeof Model>(this: T, ...relations: Array<string | string[] | Record<string, unknown>>): ModelQuery<InstanceType<T>>;
326
- /** Laravel `Model::withSum`. */
326
+ /** `Model::withSum`. */
327
327
  static withSum<T extends typeof Model>(this: T, relation: string, column: string): ModelQuery<InstanceType<T>>;
328
328
  static withAvg<T extends typeof Model>(this: T, relation: string, column: string): ModelQuery<InstanceType<T>>;
329
329
  static withMin<T extends typeof Model>(this: T, relation: string, column: string): ModelQuery<InstanceType<T>>;
@@ -335,33 +335,41 @@ export declare class Model {
335
335
  static whereAll<T extends typeof Model>(this: T, columns: string[], opOrValue: unknown, value?: unknown): ModelQuery<InstanceType<T>>;
336
336
  static whereNone<T extends typeof Model>(this: T, columns: string[], opOrValue: unknown, value?: unknown): ModelQuery<InstanceType<T>>;
337
337
  static whereKey<T extends typeof Model>(this: T, id: string | number | Array<string | number>): ModelQuery<InstanceType<T>>;
338
- /** Laravel `Model::whereUuid`. */
338
+ /** `Model::whereUuid`. */
339
339
  static whereUuid<T extends typeof Model>(this: T, column: string, value: string): ModelQuery<InstanceType<T>>;
340
- /** Laravel `Model::whereUlid`. */
340
+ /** `Model::whereUlid`. */
341
341
  static whereUlid<T extends typeof Model>(this: T, column: string, value: string): ModelQuery<InstanceType<T>>;
342
- /** Laravel `Model::join`. */
342
+ /** `Model::join`. */
343
343
  static join<T extends typeof Model>(this: T, table: string, first: string, op: string, second: string): ModelQuery<InstanceType<T>>;
344
- /** Laravel `Model::leftJoin`. */
344
+ /** `Model::leftJoin`. */
345
345
  static leftJoin<T extends typeof Model>(this: T, table: string, first: string, op: string, second: string): ModelQuery<InstanceType<T>>;
346
- /** Laravel `Model::paginate`. */
346
+ /** `Model::paginate`. */
347
347
  static paginate<T extends typeof Model>(this: T, perPage?: number, page?: number, options?: {
348
348
  path?: string;
349
349
  pageName?: string;
350
350
  }): Promise<LengthAwarePaginator<InstanceType<T>>>;
351
- /** Laravel `Model::cursorPaginate`. */
351
+ /** `Model::cursorPaginate`. */
352
352
  static cursorPaginate<T extends typeof Model>(this: T, perPage?: number, cursor?: string | null, options?: {
353
353
  path?: string;
354
354
  cursorName?: string;
355
355
  }): Promise<CursorPaginator<InstanceType<T>>>;
356
- /** Laravel `Model::create` (respects `$fillable` / `$guarded`). */
356
+ /** `Model::cursor()`: stream models from a single query. */
357
+ static cursor<T extends typeof Model>(this: T, chunkSize?: number): LazyCollection<InstanceType<T>>;
358
+ /** `Model::lazy()`: chunked iteration, one query per chunk. */
359
+ static lazy<T extends typeof Model>(this: T, chunkSize?: number): LazyCollection<InstanceType<T>>;
360
+ /** `Model::lazyById()`: chunked iteration by primary key (safe while updating). */
361
+ static lazyById<T extends typeof Model>(this: T, chunkSize?: number, column?: string): LazyCollection<InstanceType<T>>;
362
+ /** `Model::lazyByIdDesc()`. */
363
+ static lazyByIdDesc<T extends typeof Model>(this: T, chunkSize?: number, column?: string): LazyCollection<InstanceType<T>>;
364
+ /** `Model::create` (respects `$fillable` / `$guarded`). */
357
365
  static create<T extends typeof Model>(this: T, attributes: Record<string, unknown>): InstanceType<T> | Promise<InstanceType<T>>;
358
- /** Laravel `Model::forceCreate` — insert every given attribute, ignoring `$fillable`. */
366
+ /** `Model::forceCreate` — insert every given attribute, ignoring `$fillable`. */
359
367
  static forceCreate<T extends typeof Model>(this: T, useAttrs: Record<string, unknown>): InstanceType<T> | Promise<InstanceType<T>>;
360
- /** Laravel `firstOrNew`. */
368
+ /** `firstOrNew`. */
361
369
  static firstOrNew<T extends typeof Model>(this: T, attributes: Record<string, unknown>, values?: Record<string, unknown>): Promise<InstanceType<T>>;
362
- /** Laravel `firstOrCreate`. */
370
+ /** `firstOrCreate`. */
363
371
  static firstOrCreate<T extends typeof Model>(this: T, attributes: Record<string, unknown>, values?: Record<string, unknown>): Promise<InstanceType<T>>;
364
- /** Laravel `updateOrCreate`. */
372
+ /** `updateOrCreate`. */
365
373
  static updateOrCreate<T extends typeof Model>(this: T, attributes: Record<string, unknown>, values?: Record<string, unknown>): Promise<InstanceType<T>>;
366
374
  /**
367
375
  * Bulk insert. Delegates to `ModelQuery.insert` (timestamps stamped when enabled).
@@ -369,49 +377,49 @@ export declare class Model {
369
377
  */
370
378
  static insert<T extends typeof Model>(this: T, values: Record<string, unknown> | Record<string, unknown>[]): Promise<boolean>;
371
379
  /**
372
- * Laravel `Model::upsert` — bulk insert-or-update on unique conflict.
380
+ * `Model::upsert` — bulk insert-or-update on unique conflict.
373
381
  * Delegates to `ModelQuery.upsert` (timestamps stamped when enabled).
374
382
  */
375
383
  static upsert<T extends typeof Model>(this: T, values: Record<string, unknown> | Record<string, unknown>[], uniqueBy: string | string[], update?: string[] | null): Promise<number>;
376
- /** Laravel `$model->fill($attributes)`. */
384
+ /** `$model->fill($attributes)`. */
377
385
  fill(attributes: Record<string, unknown>): this;
378
- /** Laravel `$model->update($attributes)`. */
386
+ /** `$model->update($attributes)`. */
379
387
  update(attributes: Record<string, unknown>): Promise<this>;
380
388
  save(): this | Promise<this>;
381
- /** Laravel `$model->saveQuietly()`. */
389
+ /** `$model->saveQuietly()`. */
382
390
  saveQuietly(): Promise<this>;
383
- /** Laravel `$model->refresh()`. */
391
+ /** `$model->refresh()`. */
384
392
  refresh(): Promise<this>;
385
393
  /**
386
- * Laravel-style refresh under row lock (`lockForUpdate`).
394
+ * Refresh under row lock (`lockForUpdate`).
387
395
  * Reloads this instance from a locked select of the same primary key.
388
396
  */
389
397
  refreshForUpdate(): Promise<this>;
390
- /** Laravel `$model->fresh()`. */
398
+ /** `$model->fresh()`. */
391
399
  fresh(): Promise<this | null>;
392
400
  /** Eager-load relations onto this model (`load('posts')` / constrained maps). */
393
401
  load(...relations: Array<string | Record<string, unknown>>): Promise<this>;
394
402
  /** Load only relations that are not already present. */
395
403
  loadMissing(...relations: Array<string | Record<string, unknown>>): Promise<this>;
396
- /** Laravel `$model->relationLoaded($key)`. */
404
+ /** `$model->relationLoaded($key)`. */
397
405
  relationLoaded(key: string): boolean;
398
406
  /**
399
- * Laravel `$model->touches($relation)` — whether `$touches` lists this relation.
407
+ * `$model->touches($relation)` — whether `$touches` lists this relation.
400
408
  */
401
409
  touches(relation: string): boolean;
402
410
  /**
403
- * Laravel `$model->touchOwners()` — touch each relation in `$touches`.
411
+ * `$model->touchOwners()` — touch each relation in `$touches`.
404
412
  * Uses `relation.touch()` when available (BelongsTo / HasOne / HasMany);
405
413
  * otherwise loads the related model and calls `touch()` on it.
406
414
  */
407
415
  touchOwners(): Promise<void>;
408
416
  /**
409
- * Laravel `$model->touch()` — bump `updated_at` (no-op while `withoutTouching`).
417
+ * `$model->touch()` — bump `updated_at` (no-op while `withoutTouching`).
410
418
  * Saving also runs `$touches` / `touchOwners()` for listed relations.
411
419
  */
412
420
  touch(): Promise<boolean>;
413
421
  /**
414
- * Relation query builder (`$model->product()` in Laravel).
422
+ * Relation query builder (`$model->product()`).
415
423
  *
416
424
  * Define relations on `static relations` and declare the loaded property:
417
425
  * `declare product: Product | null` — then use `model.product` after `with('product')`,
@@ -420,66 +428,66 @@ export declare class Model {
420
428
  * Legacy instance methods named `product()` remain supported via the prototype.
421
429
  */
422
430
  related(name: string): unknown;
423
- /** Laravel `$model->replicate()`. */
431
+ /** `$model->replicate()`. */
424
432
  replicate(except?: string[]): this;
425
433
  delete(): Promise<void>;
426
434
  restore(): Promise<void>;
427
435
  forceDelete(): Promise<void>;
428
- /** Laravel `$model->deleteQuietly()`. */
436
+ /** `$model->deleteQuietly()`. */
429
437
  deleteQuietly(): Promise<void>;
430
438
  trashed(): boolean;
431
- /** Laravel `$model->toArray()`. */
439
+ /** `$model->toArray()`. */
432
440
  toArray(): Record<string, unknown>;
433
- /** Laravel `$model->loadCount(...$relations)`. */
441
+ /** `$model->loadCount(...$relations)`. */
434
442
  loadCount(...relations: string[]): Promise<this>;
435
- /** Laravel `$model->loadSum($relation, $column)`. */
443
+ /** `$model->loadSum($relation, $column)`. */
436
444
  loadSum(relation: string, column: string): Promise<this>;
437
445
  loadAvg(relation: string, column: string): Promise<this>;
438
446
  loadMin(relation: string, column: string): Promise<this>;
439
447
  loadMax(relation: string, column: string): Promise<this>;
440
- /** Laravel `$model->loadExists(...$relations)`. */
448
+ /** `$model->loadExists(...$relations)`. */
441
449
  loadExists(...relations: string[]): Promise<this>;
442
450
  toJSON(): Record<string, unknown>;
443
451
  /** Alias of {@link toJSON}. */
444
452
  toJson(): Record<string, unknown>;
445
- /** Laravel `$model->increment($column, $amount)`. */
453
+ /** `$model->increment($column, $amount)`. */
446
454
  increment(column: string, amount?: number): Promise<this>;
447
- /** Laravel `$model->decrement($column, $amount)`. */
455
+ /** `$model->decrement($column, $amount)`. */
448
456
  decrement(column: string, amount?: number): Promise<this>;
449
- /** Laravel `Model::destroy($ids)`. */
457
+ /** `Model::destroy($ids)`. */
450
458
  static destroy<T extends typeof Model>(this: T, ids: Array<string | number> | string | number): Promise<number>;
451
459
  /**
452
- * Laravel `Model::forceDestroy($ids)` — permanent delete by key(s).
460
+ * `Model::forceDestroy($ids)` — permanent delete by key(s).
453
461
  * Soft-delete models are found via `withTrashed()` so trashed rows are included.
454
462
  */
455
463
  static forceDestroy<T extends typeof Model>(this: T, ids: Array<string | number> | string | number): Promise<number>;
456
- /** Laravel `$this->hasMany(Related::class)`. */
464
+ /** `$this->hasMany(Related::class)`. */
457
465
  hasMany<R extends ModelClass>(related: R, foreignKey?: string, localKey?: string): HasMany<InstanceType<R>>;
458
- /** Laravel `$this->hasOne(Related::class)`. */
466
+ /** `$this->hasOne(Related::class)`. */
459
467
  hasOne<R extends ModelClass>(related: R, foreignKey?: string, localKey?: string): HasOne<InstanceType<R>>;
460
468
  /**
461
- * Laravel `$this->hasManyThrough(Related::class, Through::class)`.
469
+ * `$this->hasManyThrough(Related::class, Through::class)`.
462
470
  * Parent → Through (firstKey) → Related (secondKey).
463
471
  */
464
472
  hasManyThrough<R extends ModelClass, TThrough extends ModelClass>(related: R, through: TThrough, firstKey?: string, secondKey?: string, localKey?: string, secondLocalKey?: string): HasManyThrough<InstanceType<R>>;
465
473
  /**
466
- * Laravel `$this->hasOneThrough(Related::class, Through::class)`.
474
+ * `$this->hasOneThrough(Related::class, Through::class)`.
467
475
  */
468
476
  hasOneThrough<R extends ModelClass, TThrough extends ModelClass>(related: R, through: TThrough, firstKey?: string, secondKey?: string, localKey?: string, secondLocalKey?: string): HasOneThrough<InstanceType<R>>;
469
- /** Laravel `$this->belongsTo(Related::class)`. */
477
+ /** `$this->belongsTo(Related::class)`. */
470
478
  belongsTo<R extends ModelClass>(related: R, foreignKey?: string, ownerKey?: string): BelongsTo<InstanceType<R>>;
471
- /** Laravel `$this->belongsToMany(Related::class, pivot)`. */
479
+ /** `$this->belongsToMany(Related::class, pivot)`. */
472
480
  belongsToMany<R extends ModelClass>(related: R, table?: string, foreignPivotKey?: string, relatedPivotKey?: string): BelongsToMany<InstanceType<R>>;
473
481
  /**
474
482
  * Polymorphic many-to-many (`model_has_roles`-style pivots).
475
483
  * Third argument may be the pivot table name or an options bag (tenant/legacy morph types).
476
484
  */
477
485
  morphToMany<R extends ModelClass>(related: R, name: string, tableOrOptions?: string | MorphToManyOptions, foreignPivotKey?: string, relatedPivotKey?: string): MorphToMany<InstanceType<R>>;
478
- /** Laravel `$this->morphMany(Related::class, name)`. */
486
+ /** `$this->morphMany(Related::class, name)`. */
479
487
  morphMany<R extends ModelClass>(related: R, name: string, type?: string, id?: string, localKey?: string): MorphMany<InstanceType<R>>;
480
- /** Laravel `$this->morphOne(Related::class, name)`. */
488
+ /** `$this->morphOne(Related::class, name)`. */
481
489
  morphOne<R extends ModelClass>(related: R, name: string, type?: string, id?: string, localKey?: string): MorphOne<InstanceType<R>>;
482
- /** Laravel `$this->morphTo($name)`. */
490
+ /** `$this->morphTo($name)`. */
483
491
  morphTo(name: string, type?: string, id?: string, ownerKey?: string): MorphTo;
484
492
  }
485
493
  /** True when `value` is a Model subclass constructor (O(1) prototype check). */