自己写了一个相对简陋的实现:
from leancloud import User, Query, FriendshipQuery, utils, client
def find_friendship(class_name, user_id):
query = FriendshipQuery(class_name)
query.equal_to('user', User.create_without_data(user_id))
content = client.get('/classes/{0}'.format(class_name), query.dump()).json()
objs = []
for result in content['results']:
obj = query._new_object()
obj._finish_fetch(query._process_result(result), True)
objs.append(obj)
return objs
followee = find_friendship('_Followee', user_id)
follower = find_friendship('_Follower', user_id)