Creates a new ExerciseRepository instance
Initialized Prisma client for database operations
Creates a new exercise in the database with automatic type transformation and field mapping. Transforms exercise type from API format (dash-separated) to database format (underscore-separated) and stores flexible JSON data structure for type-specific configurations.
Exercise creation data with all required fields
Unique identifier for the exercise
Type of exercise (API format with dashes)
Type-specific exercise configuration data as JSON object
Promise resolving to the created exercise with transformed field names
Retrieves a single exercise by its unique identifier with complete type-specific data. Returns the exercise with transformed field names and type formatting for API compatibility.
Unique identifier of the exercise to retrieve
Promise resolving to exercise with type-specific data or null if not found
Retrieves a paginated list of all exercises with advanced filtering and sorting capabilities. Supports exercise type filtering with automatic format transformation and comprehensive sorting options for exercise discovery and management workflows.
Optional
options: QueryOptions = {}Query configuration options for filtering, pagination, and sorting
Page number for pagination (1-based)
Maximum number of exercises per page
Filter conditions (supports 'exercise_type' filter)
Field to sort by (must be in allowed sort fields)
Sort direction
Promise resolving to paginated exercise results with type-specific data
Updates an existing exercise with partial data and automatic type transformation. Supports updating exercise type and data with proper format conversion and field mapping. Handles undefined data values appropriately for JSON field updates.
Unique identifier of the exercise to update
Partial exercise data with fields to update
Updated exercise type (API format)
Updated type-specific exercise configuration data
Promise resolving to updated exercise with transformed field names
Deletes an exercise from the database by its unique identifier. Handles deletion gracefully with error catching to prevent application crashes. Cascade deletion will automatically remove associated lesson-exercise relationships.
Unique identifier of the exercise to delete
Promise resolving to true if deletion succeeded, false if failed or exercise not found
Checks if an exercise exists in the database by its unique identifier. Uses efficient count query to determine existence without retrieving full exercise data.
Unique identifier of the exercise to check
Promise resolving to true if exercise exists, false otherwise
Retrieves a paginated list of exercises filtered by specific exercise type. Automatically transforms exercise type from API format to database format and provides comprehensive pagination and sorting capabilities for type-specific exercise discovery.
Exercise type to filter by (API format with dashes: 'fill-in-the-blank', 'translation', etc.)
Optional
options: QueryOptions = {}Query configuration options for pagination and sorting
Page number for pagination (1-based)
Maximum number of exercises per page
Field to sort by (must be in allowed sort fields)
Sort direction
Promise resolving to paginated exercises of the specified type
Retrieves multiple exercises by their unique identifiers in a single database query. Optimized for bulk operations such as lesson assembly where multiple exercises need to be fetched efficiently. Results maintain the same order as input IDs when possible.
Array of unique exercise identifiers to retrieve
Promise resolving to array of exercises with complete type-specific data
Exercise repository class providing comprehensive data access operations for exercise management across multiple exercise types. Implements standardized CRUD operations with type-specific filtering, bulk operations, and advanced querying capabilities.