@base44-preview/sdk 0.8.20-pr.143.76a314c → 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,29 +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.
368
+ * Applies the same update to all records that match a query.
364
369
  *
365
- * Applies the same update operation to all records matching the query.
366
- * The `data` parameter must contain one or more MongoDB update operators
367
- * (e.g., `$set`, `$inc`, `$push`). Multiple operators can be combined in a
368
- * single call, but each field may only appear in one operator.
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.
369
373
  *
370
- * Results are batched in groups of up to 500 when `has_more` is `true`
374
+ * Results are batched in groups of up to 500. When `has_more` is `true`
371
375
  * in the response, call `updateMany` again with the same query to update
372
376
  * the next batch.
373
377
  *
374
- * @param query - Query object to filter which records to update. Records matching all
375
- * specified criteria will be updated.
376
- * @param data - Update operation object containing one or more MongoDB update operators.
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/).
377
389
  * Each field may only appear in one operator per call.
378
- * Supported operators: `$set`, `$rename`, `$unset`, `$inc`, `$mul`, `$min`, `$max`,
379
- * `$currentDate`, `$addToSet`, `$push`, `$pull`.
390
+ * Supported update operators include `$set`, `$rename`, `$unset`, `$inc`, `$mul`, `$min`, `$max`,
391
+ * `$currentDate`, `$addToSet`, `$push`, and `$pull`.
380
392
  * @returns Promise resolving to the update result.
381
393
  *
382
394
  * @example
383
395
  * ```typescript
384
- * // Set status to 'archived' for all completed records
385
- * const result = await base44.entities.MyEntity.updateMany(
396
+ * // Basic usage
397
+ * // Archive all completed orders
398
+ * const result = await base44.entities.Order.updateMany(
386
399
  * { status: 'completed' },
387
400
  * { $set: { status: 'archived' } }
388
401
  * );
@@ -391,8 +404,19 @@ export interface EntityHandler<T = any> {
391
404
  *
392
405
  * @example
393
406
  * ```typescript
394
- * // Combine multiple operators in a single call
395
- * 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(
396
420
  * { category: 'sales' },
397
421
  * { $set: { status: 'done' }, $inc: { view_count: 1 } }
398
422
  * );
@@ -400,11 +424,12 @@ export interface EntityHandler<T = any> {
400
424
  *
401
425
  * @example
402
426
  * ```typescript
403
- * // Handle batched updates for large datasets
427
+ * // Batched updates
428
+ * // Process all pending items in batches of 500
404
429
  * let hasMore = true;
405
430
  * let totalUpdated = 0;
406
431
  * while (hasMore) {
407
- * const result = await base44.entities.MyEntity.updateMany(
432
+ * const result = await base44.entities.Job.updateMany(
408
433
  * { status: 'pending' },
409
434
  * { $set: { status: 'processed' } }
410
435
  * );
@@ -415,27 +440,42 @@ export interface EntityHandler<T = any> {
415
440
  */
416
441
  updateMany(query: Partial<T>, data: Record<string, Record<string, any>>): Promise<UpdateManyResult>;
417
442
  /**
418
- * 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.
419
444
  *
420
- * Unlike `updateMany` which applies the same update to all matching records,
421
- * `bulkUpdate` allows different updates for each record. Each item in the
422
- * array must include an `id` field identifying which record to update.
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.
423
448
  *
424
- * **Note:** Maximum 500 items per request.
449
+ * You can update up to 500 records per request.
425
450
  *
426
- * @param data - Array of update objects (max 500). Each object must have an `id` field
427
- * and any number of fields to update.
428
- * @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.
429
457
  *
430
458
  * @example
431
459
  * ```typescript
432
- * // Update multiple records with different data
433
- * const updated = await base44.entities.MyEntity.bulkUpdate([
434
- * { id: 'entity-1', status: 'paid', amount: 999 },
435
- * { id: 'entity-2', status: 'cancelled' },
436
- * { 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 }
437
466
  * ]);
438
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
+ * ```
439
479
  */
440
480
  bulkUpdate(data: (Partial<T> & {
441
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.76a314c",
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",