@base44-preview/sdk 0.8.20-pr.143.d04635a → 0.8.20-pr.144.69d591d

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.
@@ -40,7 +40,7 @@ export interface DeleteManyResult {
40
40
  deleted: number;
41
41
  }
42
42
  /**
43
- * Result returned when updating multiple entities via a query.
43
+ * Result returned when updating multiple entities using a query.
44
44
  */
45
45
  export interface UpdateManyResult {
46
46
  /** Whether the operation was successful. */
@@ -279,6 +279,11 @@ export interface EntityHandler<T = any> {
279
279
  * Updates a record by ID with the provided data. Only the fields
280
280
  * included in the data object will be updated.
281
281
  *
282
+ * To update a single record by ID, use this method. To apply the same
283
+ * update to many records matching a query, use {@linkcode updateMany | updateMany()}.
284
+ * To update multiple specific records with different data each, use
285
+ * {@linkcode bulkUpdate | bulkUpdate()}.
286
+ *
282
287
  * @param id - The unique identifier of the record to update.
283
288
  * @param data - Object containing the fields to update.
284
289
  * @returns Promise resolving to the updated record.
@@ -360,26 +365,37 @@ export interface EntityHandler<T = any> {
360
365
  */
361
366
  bulkCreate(data: Partial<T>[]): Promise<T[]>;
362
367
  /**
363
- * Updates multiple records matching a query using a MongoDB update operator.
364
- *
365
- * Applies the same update operation to all records matching the query.
366
- * The `data` parameter must contain exactly one MongoDB update operator
367
- * (e.g., `$set`, `$inc`, `$push`).
368
- *
369
- * Results are batched — when `has_more` is `true` in the response, call
370
- * `updateMany` again with the same query to update the next batch.
371
- *
372
- * @param query - Query object to filter which records to update. Records matching all
373
- * specified criteria will be updated.
374
- * @param data - Update operation object containing exactly one MongoDB update operator.
375
- * Supported operators: `$set`, `$rename`, `$unset`, `$inc`, `$mul`, `$min`, `$max`,
376
- * `$currentDate`, `$addToSet`, `$push`, `$pull`.
368
+ * Applies the same update to all records that match a query.
369
+ *
370
+ * Use this when you need to make the same change across all records that
371
+ * match specific criteria. For example, you could set every completed order
372
+ * to "archived", or increment a counter on all active users.
373
+ *
374
+ * Results are batched in groups of up to 500. When `has_more` is `true`
375
+ * in the response, call `updateMany` again with the same query to update
376
+ * the next batch.
377
+ *
378
+ * To update a single record by ID, use {@linkcode update | update()} instead. To update
379
+ * multiple specific records with different data each, use {@linkcode bulkUpdate | bulkUpdate()}.
380
+ *
381
+ * @param query - Query object to filter which records to update. Use field-value
382
+ * pairs for exact matches, or
383
+ * [MongoDB query operators](https://www.mongodb.com/docs/manual/reference/operator/query/)
384
+ * for advanced filtering. Supported query operators include `$eq`, `$ne`, `$gt`,
385
+ * `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$and`, `$or`, `$not`, `$nor`,
386
+ * `$exists`, `$regex`, `$all`, `$elemMatch`, and `$size`.
387
+ * @param data - Update operation object containing one or more
388
+ * [MongoDB update operators](https://www.mongodb.com/docs/manual/reference/operator/update/).
389
+ * Each field may only appear in one operator per call.
390
+ * Supported update operators include `$set`, `$rename`, `$unset`, `$inc`, `$mul`, `$min`, `$max`,
391
+ * `$currentDate`, `$addToSet`, `$push`, and `$pull`.
377
392
  * @returns Promise resolving to the update result.
378
393
  *
379
394
  * @example
380
395
  * ```typescript
381
- * // Set status to 'archived' for all completed records
382
- * const result = await base44.entities.MyEntity.updateMany(
396
+ * // Basic usage
397
+ * // Archive all completed orders
398
+ * const result = await base44.entities.Order.updateMany(
383
399
  * { status: 'completed' },
384
400
  * { $set: { status: 'archived' } }
385
401
  * );
@@ -388,20 +404,32 @@ export interface EntityHandler<T = any> {
388
404
  *
389
405
  * @example
390
406
  * ```typescript
391
- * // Increment a counter on all matching records
392
- * const result = await base44.entities.MyEntity.updateMany(
407
+ * // Multiple query operators
408
+ * // Flag urgent items that haven't been handled yet
409
+ * const result = await base44.entities.Task.updateMany(
410
+ * { priority: { $in: ['high', 'critical'] }, status: { $ne: 'done' } },
411
+ * { $set: { flagged: true } }
412
+ * );
413
+ * ```
414
+ *
415
+ * @example
416
+ * ```typescript
417
+ * // Multiple update operators
418
+ * // Close out sales records and bump the view count
419
+ * const result = await base44.entities.Deal.updateMany(
393
420
  * { category: 'sales' },
394
- * { $inc: { view_count: 1 } }
421
+ * { $set: { status: 'done' }, $inc: { view_count: 1 } }
395
422
  * );
396
423
  * ```
397
424
  *
398
425
  * @example
399
426
  * ```typescript
400
- * // Handle batched updates for large datasets
427
+ * // Batched updates
428
+ * // Process all pending items in batches of 500
401
429
  * let hasMore = true;
402
430
  * let totalUpdated = 0;
403
431
  * while (hasMore) {
404
- * const result = await base44.entities.MyEntity.updateMany(
432
+ * const result = await base44.entities.Job.updateMany(
405
433
  * { status: 'pending' },
406
434
  * { $set: { status: 'processed' } }
407
435
  * );
@@ -412,25 +440,42 @@ export interface EntityHandler<T = any> {
412
440
  */
413
441
  updateMany(query: Partial<T>, data: Record<string, Record<string, any>>): Promise<UpdateManyResult>;
414
442
  /**
415
- * Updates multiple records in a single request, each with its own update data.
443
+ * Updates the specified records in a single request, each with its own data.
444
+ *
445
+ * Use this when you already know which records to update and each one needs
446
+ * different field values. For example, you could update the status and amount
447
+ * on three separate invoices in one call.
416
448
  *
417
- * Unlike `updateMany` which applies the same update to all matching records,
418
- * `bulkUpdate` allows different updates for each record. Each item in the
419
- * array must include an `id` field identifying which record to update.
449
+ * You can update up to 500 records per request.
420
450
  *
421
- * @param data - Array of update objects. Each object must have an `id` field
422
- * and any number of fields to update.
423
- * @returns Promise resolving to an array of updated records.
451
+ * To apply the same update to all records matching a query, use
452
+ * {@linkcode updateMany | updateMany()}. To update a single record by ID, use
453
+ * {@linkcode update | update()}.
454
+ *
455
+ * @param data - Array of objects to update. Each object must contain an `id` field identifying which record to update and any fields to change.
456
+ * @returns Promise resolving to an array of the updated records.
424
457
  *
425
458
  * @example
426
459
  * ```typescript
427
- * // Update multiple records with different data
428
- * const updated = await base44.entities.MyEntity.bulkUpdate([
429
- * { id: 'entity-1', status: 'paid', amount: 999 },
430
- * { id: 'entity-2', status: 'cancelled' },
431
- * { id: 'entity-3', name: 'Renamed Item' }
460
+ * // Basic usage
461
+ * // Update three invoices with different statuses and amounts
462
+ * const updated = await base44.entities.Invoice.bulkUpdate([
463
+ * { id: 'inv-1', status: 'paid', amount: 999 },
464
+ * { id: 'inv-2', status: 'cancelled' },
465
+ * { id: 'inv-3', amount: 450 }
432
466
  * ]);
433
467
  * ```
468
+ *
469
+ * @example
470
+ * ```typescript
471
+ * // More than 500 items
472
+ * // Reassign each task to a different owner in batches
473
+ * const allUpdates = reassignments.map(r => ({ id: r.taskId, owner: r.newOwner }));
474
+ * for (let i = 0; i < allUpdates.length; i += 500) {
475
+ * const batch = allUpdates.slice(i, i + 500);
476
+ * await base44.entities.Task.bulkUpdate(batch);
477
+ * }
478
+ * ```
434
479
  */
435
480
  bulkUpdate(data: (Partial<T> & {
436
481
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.20-pr.143.d04635a",
3
+ "version": "0.8.20-pr.144.69d591d",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",