map method

  1. @override
SongData map(
  1. Map<String, dynamic> data, {
  2. String? tablePrefix,
})

Maps the given row returned by the database into the fitting data class.

Implementation

@override
SongData map(Map<String, dynamic> data, {String? tablePrefix}) {
  final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
  return SongData(
    id: attachedDatabase.typeMapping.read(
      DriftSqlType.int,
      data['${effectivePrefix}id'],
    )!,
    name: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}name'],
    )!,
    locked: attachedDatabase.typeMapping.read(
      DriftSqlType.bool,
      data['${effectivePrefix}locked'],
    )!,
    published: attachedDatabase.typeMapping.read(
      DriftSqlType.bool,
      data['${effectivePrefix}published'],
    )!,
    imagePath: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}image_path'],
    ),
    description: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}description'],
    ),
    note: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}note'],
    ),
    youtubeCode: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}youtube_code'],
    ),
    youtubeVideoInfo: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}youtube_video_info'],
    ),
    albumId: attachedDatabase.typeMapping.read(
      DriftSqlType.int,
      data['${effectivePrefix}album_id'],
    )!,
  );
}