import { getDBConnection } from '../sqlite';
import { MediaAttachment } from '@/types/workout.types';

export const mediaRepository = {
  async getMediaByWorkoutId(workoutId: string): Promise<MediaAttachment[]> {
    const db = await getDBConnection();
    const rows: any[] = await db.getAllAsync(
      'SELECT latitude as lat, longitude as lng, type, file_uri as uri, caption, timestamp FROM media_attachments WHERE workout_id = ?',
      [workoutId]
    );
    return rows;
  }
};
