def find_non_friends(user): ret = [] for i in list(db.find_participants({'username': {'$ne': user['username']}})): if not i['username'] in user['contributors']: ret.append(i) return ret
def search_participants(q): ret = [] for f in db.find_participants(): if q['name'].lower() in f['name'].lower(): ret.append(f) return ret