upsert method

Future<void> upsert(
  1. UserId userId,
  2. ChatId chatId
)

Creates or updates the provided chatId in the database.

Implementation

Future<void> upsert(UserId userId, ChatId chatId) async {
  _cache[userId] = chatId;

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