def get_followers(db, uid, timestamp=None):
  """
  Returns an iterable containing all follower ids for the user with
  the given uid.  If :timestamp: is used, it's a dictiorary containing
  criteria on the "date" field.
  """
  criteria = { 'follows': uid }
  if timestamp: criteria['date'] = timestamp
  followers = db.follow.aggregate(
    [ { '$match': criteria },
      { '$group': { '_id': '$id'} }
    ], allowDiskUse=True)
  return (x['_id'] for x in followers)
  #return db.follow.find({'follows': uid}).distinct('id')
  #return frozenset(x['id'] for x in db.follow.find(criteria))