示例#1
0
 public static Task <IEnumerable <PKGroup> > QueryMemberGroups(this IPKConnection conn, MemberId id) =>
 conn.QueryAsync <PKGroup>(
     "select groups.* from group_members inner join groups on group_members.group_id = groups.id where group_members.member_id = @Id",
     new { Id = id });
示例#2
0
 public static Task <MemberGuildSettings> QueryOrInsertMemberGuildConfig(
     this IPKConnection conn, ulong guild, MemberId member) =>
 conn.QueryFirstAsync <MemberGuildSettings>(
     "insert into member_guild (guild, member) values (@guild, @member) on conflict (guild, member) do update set guild = @guild, member = @member returning *",
     new { guild, member });
示例#3
0
 public Task DeleteMember(IPKConnection conn, MemberId id)
 {
     _logger.Information("Deleted {MemberId}", id);
     return(conn.ExecuteAsync("delete from members where id = @Id", new { Id = id }));
 }
示例#4
0
 public static Task <PKMember?> QueryMember(this IPKConnection conn, MemberId id) =>
 conn.QueryFirstOrDefaultAsync <PKMember?>("select * from members where id = @id", new { id });
示例#5
0
        public async Task AddMessage(IPKConnection conn, ulong senderId, ulong guildId, ulong channelId, ulong postedMessageId, ulong triggerMessageId, MemberId proxiedMemberId)
        {
            // "on conflict do nothing" in the (pretty rare) case of duplicate events coming in from Discord, which would lead to a DB error before
            await conn.ExecuteAsync("insert into messages(mid, guild, channel, member, sender, original_mid) values(@MessageId, @GuildId, @ChannelId, @MemberId, @SenderId, @OriginalMid) on conflict do nothing", new {
                MessageId   = postedMessageId,
                GuildId     = guildId,
                ChannelId   = channelId,
                MemberId    = proxiedMemberId,
                SenderId    = senderId,
                OriginalMid = triggerMessageId
            });

            _logger.Debug("Stored message {Message} in channel {Channel}", postedMessageId, channelId);
        }
示例#6
0
 public async Task <PKMember> GetMemberById(MemberId id)
 {
     using (var conn = await _conn.Obtain())
         return(await conn.QuerySingleOrDefaultAsync <PKMember>("select * from members where id = @Id", new { Id = id }));
 }
示例#7
0
 public static Task DeleteMember(this IPKConnection conn, MemberId id) =>
 conn.ExecuteAsync("delete from members where id = @Id", new { Id = id });
 public Task RemoveGroupsFromMember(IPKConnection conn, MemberId member, IReadOnlyCollection <GroupId> groups)
 {
     _logger.Information("Removed groups from {MemberId}: {GroupIds}", member, groups);
     return(conn.ExecuteAsync("delete from group_members where member_id = @Member and group_id = any(@Groups)",
                              new { Member = @member, Groups = groups.ToArray() }));
 }
 public IAsyncEnumerable <PKGroup> GetMemberGroups(IPKConnection conn, MemberId id) =>
 conn.QueryStreamAsync <PKGroup>(
     "select groups.* from group_members inner join groups on group_members.group_id = groups.id where group_members.member_id = @Id",
     new { Id = id });