async def get_all_not_in(self, not_in) -> List[BannedUser]: not_in = list(map(int, not_in)) async with self.pool.acquire() as conn: rows = await conn.fetch( f"SELECT * FROM banlist WHERE NOT (id = ANY($1::BIGINT[]))", not_in) return [BannedUser(row['id'], row['reason']) for row in rows]
async def get_user(self, uid: int) -> Optional[BannedUser]: """Fetch a users document Args: uid: User ID Returns: None or the Document """ async with self.pool.acquire() as conn: row = await conn.fetchrow("SELECT * FROM banlist WHERE id = $1", uid) if row: return BannedUser(row['id'], row['reason'])
async def get_all(self) -> List[BannedUser]: async with self.pool.acquire() as conn: rows = await conn.fetch('SELECT * FROM banlist') return [BannedUser(row['id'], row['reason']) for row in rows]
async def get_with_reason(self, reason) -> List[BannedUser]: async with self.pool.acquire() as conn: rows = await conn.fetch( "SELECT * FROM banlist WHERE lower(reason) LIKE lower($1)", reason) return [BannedUser(row['id'], row['reason']) for row in rows]
async def get_multiple(self, uids) -> List[BannedUser]: async with self.pool.acquire() as conn: rows = await conn.fetch( f"SELECT * FROM banlist WHERE id = ANY($1::BIGINT[])", uids) return [BannedUser(row['id'], row['reason']) for row in rows]