@base44-preview/sdk 0.8.20-pr.142.985ee7b → 0.8.20-pr.143.76a314c
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
|
@@ -4,7 +4,7 @@ import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from
|
|
|
4
4
|
export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
|
|
5
5
|
export type { Base44Client, CreateClientConfig, CreateClientOptions, Base44ErrorJSON, };
|
|
6
6
|
export * from "./types.js";
|
|
7
|
-
export type { DeleteManyResult, DeleteResult, EntitiesModule, EntityHandler, EntityRecord, EntityTypeRegistry, ImportResult, RealtimeEventType, RealtimeEvent, RealtimeCallback, SortField, } from "./modules/entities.types.js";
|
|
7
|
+
export type { DeleteManyResult, DeleteResult, EntitiesModule, EntityHandler, EntityRecord, EntityTypeRegistry, ImportResult, RealtimeEventType, RealtimeEvent, RealtimeCallback, SortField, UpdateManyResult, } from "./modules/entities.types.js";
|
|
8
8
|
export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
|
|
9
9
|
export type { IntegrationsModule, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
|
|
10
10
|
export type { FunctionsModule, FunctionName, FunctionNameRegistry, } from "./modules/functions.types.js";
|
package/dist/modules/entities.js
CHANGED
|
@@ -106,6 +106,14 @@ function createEntityHandler(axios, appId, entityName, getSocket) {
|
|
|
106
106
|
async bulkCreate(data) {
|
|
107
107
|
return axios.post(`${baseURL}/bulk`, data);
|
|
108
108
|
},
|
|
109
|
+
// Update multiple entities matching a query using a MongoDB update operator
|
|
110
|
+
async updateMany(query, data) {
|
|
111
|
+
return axios.patch(`${baseURL}/update-many`, { query, data });
|
|
112
|
+
},
|
|
113
|
+
// Update multiple entities by ID, each with its own update data
|
|
114
|
+
async bulkUpdate(data) {
|
|
115
|
+
return axios.put(`${baseURL}/bulk`, data);
|
|
116
|
+
},
|
|
109
117
|
// Import entities from a file
|
|
110
118
|
async importEntities(file) {
|
|
111
119
|
const formData = new FormData();
|
|
@@ -39,6 +39,17 @@ export interface DeleteManyResult {
|
|
|
39
39
|
/** Number of entities that were deleted. */
|
|
40
40
|
deleted: number;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Result returned when updating multiple entities via a query.
|
|
44
|
+
*/
|
|
45
|
+
export interface UpdateManyResult {
|
|
46
|
+
/** Whether the operation was successful. */
|
|
47
|
+
success: boolean;
|
|
48
|
+
/** Number of entities that were updated. */
|
|
49
|
+
updated: number;
|
|
50
|
+
/** Whether there are more entities matching the query that were not updated in this batch. When `true`, call `updateMany` again with the same query to update the next batch. */
|
|
51
|
+
has_more: boolean;
|
|
52
|
+
}
|
|
42
53
|
/**
|
|
43
54
|
* Result returned when importing entities from a file.
|
|
44
55
|
*
|
|
@@ -348,6 +359,87 @@ export interface EntityHandler<T = any> {
|
|
|
348
359
|
* ```
|
|
349
360
|
*/
|
|
350
361
|
bulkCreate(data: Partial<T>[]): Promise<T[]>;
|
|
362
|
+
/**
|
|
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 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.
|
|
369
|
+
*
|
|
370
|
+
* Results are batched in groups of up to 500 — when `has_more` is `true`
|
|
371
|
+
* in the response, call `updateMany` again with the same query to update
|
|
372
|
+
* the next batch.
|
|
373
|
+
*
|
|
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.
|
|
377
|
+
* 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`.
|
|
380
|
+
* @returns Promise resolving to the update result.
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* // Set status to 'archived' for all completed records
|
|
385
|
+
* const result = await base44.entities.MyEntity.updateMany(
|
|
386
|
+
* { status: 'completed' },
|
|
387
|
+
* { $set: { status: 'archived' } }
|
|
388
|
+
* );
|
|
389
|
+
* console.log(`Updated ${result.updated} records`);
|
|
390
|
+
* ```
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```typescript
|
|
394
|
+
* // Combine multiple operators in a single call
|
|
395
|
+
* const result = await base44.entities.MyEntity.updateMany(
|
|
396
|
+
* { category: 'sales' },
|
|
397
|
+
* { $set: { status: 'done' }, $inc: { view_count: 1 } }
|
|
398
|
+
* );
|
|
399
|
+
* ```
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```typescript
|
|
403
|
+
* // Handle batched updates for large datasets
|
|
404
|
+
* let hasMore = true;
|
|
405
|
+
* let totalUpdated = 0;
|
|
406
|
+
* while (hasMore) {
|
|
407
|
+
* const result = await base44.entities.MyEntity.updateMany(
|
|
408
|
+
* { status: 'pending' },
|
|
409
|
+
* { $set: { status: 'processed' } }
|
|
410
|
+
* );
|
|
411
|
+
* totalUpdated += result.updated;
|
|
412
|
+
* hasMore = result.has_more;
|
|
413
|
+
* }
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
416
|
+
updateMany(query: Partial<T>, data: Record<string, Record<string, any>>): Promise<UpdateManyResult>;
|
|
417
|
+
/**
|
|
418
|
+
* Updates multiple records in a single request, each with its own update data.
|
|
419
|
+
*
|
|
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.
|
|
423
|
+
*
|
|
424
|
+
* **Note:** Maximum 500 items per request.
|
|
425
|
+
*
|
|
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.
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* ```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' }
|
|
437
|
+
* ]);
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
bulkUpdate(data: (Partial<T> & {
|
|
441
|
+
id: string;
|
|
442
|
+
})[]): Promise<T[]>;
|
|
351
443
|
/**
|
|
352
444
|
* Imports records from a file.
|
|
353
445
|
*
|