map method

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

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

Implementation

@override
BookData map(Map<String, dynamic> data, {String? tablePrefix}) {
  final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
  return BookData(
    id: attachedDatabase.typeMapping.read(
      DriftSqlType.int,
      data['${effectivePrefix}id'],
    )!,
    code: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}code'],
    )!,
    title: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}title'],
    )!,
    seqNum: attachedDatabase.typeMapping.read(
      DriftSqlType.int,
      data['${effectivePrefix}seq_num'],
    )!,
    published: attachedDatabase.typeMapping.read(
      DriftSqlType.bool,
      data['${effectivePrefix}published'],
    )!,
    locked: attachedDatabase.typeMapping.read(
      DriftSqlType.bool,
      data['${effectivePrefix}locked'],
    )!,
    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'],
    ),
  );
}