Skip to content

Commit 8c2cfca

Browse files
committed
feat(sdk): added support for bulk operations on entities
1 parent b7241db commit 8c2cfca

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

src/modules/entities.types.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,18 @@ export interface EntityHandler<T = any> {
395395
* Updates multiple records matching a query using a MongoDB update operator.
396396
*
397397
* Applies the same update operation to all records matching the query.
398-
* The `data` parameter must contain exactly one MongoDB update operator
399-
* (e.g., `$set`, `$inc`, `$push`).
398+
* The `data` parameter must contain one or more MongoDB update operators
399+
* (e.g., `$set`, `$inc`, `$push`). Multiple operators can be combined in a
400+
* single call, but each field may only appear in one operator.
400401
*
401-
* Results are batched — when `has_more` is `true` in the response, call
402-
* `updateMany` again with the same query to update the next batch.
402+
* Results are batched in groups of up to 500 — when `has_more` is `true`
403+
* in the response, call `updateMany` again with the same query to update
404+
* the next batch.
403405
*
404406
* @param query - Query object to filter which records to update. Records matching all
405407
* specified criteria will be updated.
406-
* @param data - Update operation object containing exactly one MongoDB update operator.
408+
* @param data - Update operation object containing one or more MongoDB update operators.
409+
* Each field may only appear in one operator per call.
407410
* Supported operators: `$set`, `$rename`, `$unset`, `$inc`, `$mul`, `$min`, `$max`,
408411
* `$currentDate`, `$addToSet`, `$push`, `$pull`.
409412
* @returns Promise resolving to the update result.
@@ -420,10 +423,10 @@ export interface EntityHandler<T = any> {
420423
*
421424
* @example
422425
* ```typescript
423-
* // Increment a counter on all matching records
426+
* // Combine multiple operators in a single call
424427
* const result = await base44.entities.MyEntity.updateMany(
425428
* { category: 'sales' },
426-
* { $inc: { view_count: 1 } }
429+
* { $set: { status: 'done' }, $inc: { view_count: 1 } }
427430
* );
428431
* ```
429432
*
@@ -451,7 +454,9 @@ export interface EntityHandler<T = any> {
451454
* `bulkUpdate` allows different updates for each record. Each item in the
452455
* array must include an `id` field identifying which record to update.
453456
*
454-
* @param data - Array of update objects. Each object must have an `id` field
457+
* **Note:** Maximum 500 items per request.
458+
*
459+
* @param data - Array of update objects (max 500). Each object must have an `id` field
455460
* and any number of fields to update.
456461
* @returns Promise resolving to an array of updated records.
457462
*

0 commit comments

Comments
 (0)