def api_get_users(*, page='1'): page_index = get_page_index(page) num = yield from User.find_num('count(id)') p = Page(num, page_index) if num == 0: return dict(page=p, users=()) users = yield from User.find_all(orderBy='created_at desc', limit=(p.offset, p.limit)) for u in users: u.passwd = '******' return dict(page=p, users=users)
def find_num_test(loop): yield from orm.create_pool(loop=loop, user='******', password='******', db='myblog') count = yield from User.find_num('email') print(count)