@@ -333,25 +333,51 @@ export class ObjectQLDataSource<T = any> implements DataSource<T> {
333333 *
334334 * @param resource - Object name
335335 * @param operation - Operation type
336- * @param data - Bulk data
336+ * @param data - Bulk data or filters for update/delete
337337 * @returns Promise resolving to operation results
338338 */
339339 async bulk (
340340 resource : string ,
341341 operation : 'create' | 'update' | 'delete' ,
342- data : Partial < T > [ ]
342+ data : Partial < T > [ ] | any
343343 ) : Promise < T [ ] > {
344344 try {
345345 if ( operation === 'create' ) {
346346 const response = await this . client . createMany < T > ( resource , data ) ;
347347 return response . items || [ ] ;
348348 } else if ( operation === 'update' ) {
349- // For bulk updates, we need to use updateMany with filters
350- // This is a simplified implementation
351- throw new Error ( 'Bulk update not yet implemented with SDK' ) ;
349+ // For bulk updates with SDK, we need filters and update data
350+ // This is a limitation - the old API accepted array of records
351+ // The new SDK requires filters + data
352+ if ( Array . isArray ( data ) ) {
353+ // If array of records is provided, we need to update them individually
354+ // This is less efficient but maintains compatibility
355+ const results : T [ ] = [ ] ;
356+ for ( const item of data ) {
357+ if ( '_id' in item && item . _id ) {
358+ const updated = await this . client . update < T > ( resource , item . _id , item ) ;
359+ results . push ( updated as T ) ;
360+ }
361+ }
362+ return results ;
363+ } else {
364+ throw new Error ( 'Bulk update requires array of records with _id field' ) ;
365+ }
352366 } else if ( operation === 'delete' ) {
353- // For bulk deletes, we need to use deleteMany with filters
354- throw new Error ( 'Bulk delete not yet implemented with SDK' ) ;
367+ // For bulk deletes with SDK, similar approach
368+ if ( Array . isArray ( data ) ) {
369+ // Delete each record individually
370+ const results : T [ ] = [ ] ;
371+ for ( const item of data ) {
372+ if ( '_id' in item && item . _id ) {
373+ await this . client . delete ( resource , item . _id ) ;
374+ results . push ( item as T ) ;
375+ }
376+ }
377+ return results ;
378+ } else {
379+ throw new Error ( 'Bulk delete requires array of records with _id field' ) ;
380+ }
355381 }
356382
357383 throw new Error ( `Unknown bulk operation: ${ operation } ` ) ;
0 commit comments