@yihuangdb/storage-object
Version:
A Node.js storage object layer library using Redis OM
42 lines • 1.36 kB
TypeScript
/**
* Atomic batch operations for StorageObject
* Provides true atomicity for batch create, update, and delete operations
*/
export interface BatchOptions {
atomic?: boolean;
rollbackOnError?: boolean;
validate?: boolean;
chunkSize?: number;
}
export interface BatchResult<T> {
success: boolean;
count: number;
entities?: T[];
errors?: Error[];
rollbackCount?: number;
}
export declare class BatchOperationError extends Error {
readonly operation: 'create' | 'update' | 'delete';
readonly failedCount: number;
readonly successCount: number;
readonly errors: Error[];
constructor(message: string, operation: 'create' | 'update' | 'delete', failedCount: number, successCount: number, errors: Error[]);
}
/**
* Helper to convert entity to Redis hash format
*/
export declare function entityToHash(entity: any): Record<string, string>;
/**
* Execute operations in chunks for better performance
*/
export declare function executeInChunks<T>(items: T[], chunkSize: number, operation: (chunk: T[]) => Promise<any>): Promise<any[]>;
/**
* Rollback helper for failed operations
*/
export declare class RollbackManager {
private rollbackActions;
addRollback(action: () => Promise<void>): void;
executeRollback(): Promise<number>;
clear(): void;
}
//# sourceMappingURL=batch-operations.d.ts.map