map method

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

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

Implementation

@override
CacheItem map(Map<String, dynamic> data, {String? tablePrefix}) {
  final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
  return CacheItem(
    key: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}key'],
    )!,
    data: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}data'],
    )!,
    createdAt: attachedDatabase.typeMapping.read(
      DriftSqlType.dateTime,
      data['${effectivePrefix}created_at'],
    )!,
    expiresAt: attachedDatabase.typeMapping.read(
      DriftSqlType.dateTime,
      data['${effectivePrefix}expires_at'],
    )!,
    priority: attachedDatabase.typeMapping.read(
      DriftSqlType.int,
      data['${effectivePrefix}priority'],
    )!,
    size: attachedDatabase.typeMapping.read(
      DriftSqlType.int,
      data['${effectivePrefix}size'],
    )!,
  );
}