@guren/orm 1.0.0-rc.26 → 1.0.0-rc.27

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.d.ts CHANGED
@@ -210,10 +210,22 @@ declare class QueryBuilder<TRecord extends PlainObject = PlainObject, TResult ex
210
210
  }): Promise<PaginatedResult<TResult>>;
211
211
  /**
212
212
  * Bulk update records matching the current conditions.
213
+ *
214
+ * Mass-assignment protection applies exactly as in `Model.update()`:
215
+ * with a `fillable` allowlist, out-of-allowlist keys throw a
216
+ * MassAssignmentException. Note that bulk updates skip model hooks,
217
+ * observers, mutators, and casts by design.
218
+ *
213
219
  * @param data - Data to set on matching records
214
220
  * @returns The updated record (adapter-dependent)
215
221
  */
216
222
  update(data: PlainObject): Promise<TRecord>;
223
+ /**
224
+ * Bulk update bypassing mass-assignment protection. Use for trusted,
225
+ * server-side-assembled data — never for raw request input.
226
+ */
227
+ forceUpdate(data: PlainObject): Promise<TRecord>;
228
+ private runBulkUpdate;
217
229
  /**
218
230
  * Bulk delete records matching the current conditions.
219
231
  * @returns Number of deleted records (adapter-dependent)
@@ -433,7 +445,7 @@ interface PaginateOptions<TRecord extends PlainObject = PlainObject> {
433
445
  orderBy?: OrderByInput<TRecord>;
434
446
  }
435
447
  /** Pagination metadata returned with paginated results. */
436
- interface PaginationMeta {
448
+ interface ModelPaginationMeta {
437
449
  /** Total number of records matching the query */
438
450
  total: number;
439
451
  /** Number of records per page */
@@ -454,7 +466,7 @@ interface PaginatedResult<TRecord extends PlainObject = PlainObject> {
454
466
  /** Records for the current page */
455
467
  data: TRecord[];
456
468
  /** Pagination metadata */
457
- meta: PaginationMeta;
469
+ meta: ModelPaginationMeta;
458
470
  }
459
471
  /**
460
472
  * Interface for ORM adapters that power the Model class.
@@ -1587,4 +1599,4 @@ declare function serializeRecord(record: PlainObject, options: {
1587
1599
  /** Serialize an array of records. */
1588
1600
  declare function serializeRecords(records: PlainObject[], options: Parameters<typeof serializeRecord>[1]): PlainObject[];
1589
1601
 
1590
- export { type AccessorDefinitions, type AccessorFn, type BelongsToManyRecord, type BelongsToManyRelationResult, type BelongsToRecord, type BelongsToRelationResult, type CastType, DrizzleAdapter, type FindManyOptions, GlobalScopeRegistry, type GroupCondition, type HasManyRecord, type HasManyRelationResult, type HasManyThroughRecord, type HasManyThroughRelationResult, type HasOneRecord, type HasOneRelationResult, type HookCallback, type HookName, type InferModelInsert, type InferModelRecord, MassAssignmentException, type MigrationStatusEntry, Model, type ModelHooks, ModelNotFoundException, type ModelObserver, type ModelObserverConstructor, type MorphManyRecord, type MorphManyRelationResult, type MorphToRecord, type MorphToRelationResult, type MutatorDefinitions, type MutatorFn, type MySqlDatabase, type MySqlDatabaseOptions, type ORMAdapter, type ORMAdapterAdvanced, type OrderByClause, type OrderByInput, type OrderDefinition, type OrderDirection, type PaginateOptions, type PaginatedResult, type PaginationMeta, type PlainObject, type PostgresDatabase, type PostgresDatabaseOptions, QueryBuilder, type QueryBuilderOptions, type ScopeFunction, type SeederContext, type SeederHandler, type SimpleCondition, SoftDeletes, type SoftDeletesStatic, type SqliteDatabase, type SqliteDatabaseOptions, type TransactionHandle, type TransactionModelScope, type WhereClause, type WhereCondition, type WhereOperator, type WithRelations, applyAccessors, applyMutators, buildDrizzleConditions, createMySqlDatabase, createPostgresDatabase, createSqliteDatabase, defineModel, defineSeeder, executeHook, executeObservers, loadSeeders, runSeeders, serializeRecord, serializeRecords };
1602
+ export { type AccessorDefinitions, type AccessorFn, type BelongsToManyRecord, type BelongsToManyRelationResult, type BelongsToRecord, type BelongsToRelationResult, type CastType, DrizzleAdapter, type FindManyOptions, GlobalScopeRegistry, type GroupCondition, type HasManyRecord, type HasManyRelationResult, type HasManyThroughRecord, type HasManyThroughRelationResult, type HasOneRecord, type HasOneRelationResult, type HookCallback, type HookName, type InferModelInsert, type InferModelRecord, MassAssignmentException, type MigrationStatusEntry, Model, type ModelHooks, ModelNotFoundException, type ModelObserver, type ModelObserverConstructor, type ModelPaginationMeta, type MorphManyRecord, type MorphManyRelationResult, type MorphToRecord, type MorphToRelationResult, type MutatorDefinitions, type MutatorFn, type MySqlDatabase, type MySqlDatabaseOptions, type ORMAdapter, type ORMAdapterAdvanced, type OrderByClause, type OrderByInput, type OrderDefinition, type OrderDirection, type PaginateOptions, type PaginatedResult, type PlainObject, type PostgresDatabase, type PostgresDatabaseOptions, QueryBuilder, type QueryBuilderOptions, type ScopeFunction, type SeederContext, type SeederHandler, type SimpleCondition, SoftDeletes, type SoftDeletesStatic, type SqliteDatabase, type SqliteDatabaseOptions, type TransactionHandle, type TransactionModelScope, type WhereClause, type WhereCondition, type WhereOperator, type WithRelations, applyAccessors, applyMutators, buildDrizzleConditions, createMySqlDatabase, createPostgresDatabase, createSqliteDatabase, defineModel, defineSeeder, executeHook, executeObservers, loadSeeders, runSeeders, serializeRecord, serializeRecords };
package/dist/index.js CHANGED
@@ -763,20 +763,38 @@ var QueryBuilder = class {
763
763
  }
764
764
  /**
765
765
  * Bulk update records matching the current conditions.
766
+ *
767
+ * Mass-assignment protection applies exactly as in `Model.update()`:
768
+ * with a `fillable` allowlist, out-of-allowlist keys throw a
769
+ * MassAssignmentException. Note that bulk updates skip model hooks,
770
+ * observers, mutators, and casts by design.
771
+ *
766
772
  * @param data - Data to set on matching records
767
773
  * @returns The updated record (adapter-dependent)
768
774
  */
769
775
  async update(data) {
776
+ return this.runBulkUpdate(data, true);
777
+ }
778
+ /**
779
+ * Bulk update bypassing mass-assignment protection. Use for trusted,
780
+ * server-side-assembled data — never for raw request input.
781
+ */
782
+ async forceUpdate(data) {
783
+ return this.runBulkUpdate(data, false);
784
+ }
785
+ async runBulkUpdate(data, applyFillable) {
770
786
  if (!this.adapter.update) {
771
787
  throw new Error("Configured adapter does not support update operations.");
772
788
  }
789
+ const model = this.modelClass;
790
+ const payload = applyFillable ? model.filterFillable(data) : { ...data };
773
791
  const advancedAdapter = this.adapter;
774
792
  if (typeof advancedAdapter.updateAdvanced === "function") {
775
- return advancedAdapter.updateAdvanced(this.table, this.conditions, data, { trx: this.options.trx });
793
+ return advancedAdapter.updateAdvanced(this.table, this.conditions, payload, { trx: this.options.trx });
776
794
  }
777
795
  const simpleWhere = this.toSimpleWhereClause();
778
796
  if (simpleWhere) {
779
- return this.adapter.update(this.table, simpleWhere, data, { trx: this.options.trx });
797
+ return this.adapter.update(this.table, simpleWhere, payload, { trx: this.options.trx });
780
798
  }
781
799
  throw new Error("Advanced conditions require an adapter that supports updateAdvanced.");
782
800
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/orm",
3
- "version": "1.0.0-rc.26",
3
+ "version": "1.0.0-rc.27",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {