upsertBulk method

Future<Iterable<DtoChatMember>> upsertBulk(
  1. ChatId chatId,
  2. Iterable<DtoChatMember> members
)

Creates or updates the provided members in the database.

Implementation

Future<Iterable<DtoChatMember>> upsertBulk(
  ChatId chatId,
  Iterable<DtoChatMember> members,
) async {
  Log.debug('upsertBulk($chatId, $members)');

  await safe((db) async {
    for (var member in members) {
      final ChatMemberRow row = member.toDb(chatId);
      db.into(db.chatMembers).insert(row, onConflict: DoUpdate((_) => row));
    }
  }, tag: 'chat_member.upsertBulk($chatId, ${members.length} items)');

  return members;
}