upsert method

Future<void> upsert(
  1. MonologKind kind,
  2. ChatId chatId
)

Creates or updates the provided chatId in the database.

Implementation

Future<void> upsert(MonologKind kind, ChatId chatId) async {
  _cache[kind.name] = chatId;

  await safe((db) async {
    await db
        .into(db.monologs)
        .insert(chatId.toDb(kind), mode: InsertMode.insertOrReplace);
  }, tag: 'monolog.upsert(${kind.name}, $chatId)');
}