我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用models.User.findNumber()。
def index(request,*,page='1'): page_index = get_page_index(page) num = await Blog.findNumber('count(id)') page = Page(num,page_index) if page == 0: blogs = [] else: blogs = await Blog.findAll(orderBy = 'created_at desc',limit=(page.offset,page.limit)) return{ '__template__' : 'blogs.html', 'page' : page, 'blogs' : blogs, '__user__' : request.__user__ }
def api_comments(*,page='1'): page_index = get_page_index(page) num = await Comment.findNumber('count(id)') p = Page(num,page_index) if num == 0: return dict(page=p,comments=()) comments = await Comment.findAll(orderBy='created_at desc',limit=(p.offset,p.limit)) return dict(page=p,comments=comments)
def api_get_users(*,page='1'): page_index = get_page_index(page) num = await User.findNumber('count(id)') p = Page(num,page_index) if num ==0 : return dict(page=p,users=()) users = await User.findAll(orderBy='created_at desc',limit=(p.offset,p.limit)) for u in users: u.passwd = '******' return dict(page=p,users=users)
def api_blogs(*,page='1'): page_index = get_page_index(page) num = await Blog.findNumber('count(id)') p = Page(num,page_index) if num == 0: return dict(page=0,blogs={}) blogs = await Blog.findAll(orderBy='created_at desc',limit=(p.offset,p.limit)) return dict(page=p,blogs=blogs)
def find(): await orm.create_pool(loop, user='root', password='password', db='awesome') all = await User.findAll() print(all) pk = await User.find('00149276202953187d8d3176f894f1fa82d9caa7d36775a000') print(pk) num = await User.findNumber('email') print(num) await orm.destory_pool()
def index(*, page='1'): page_index = get_page_index(page) num = yield from Blog.findNumber('count(id)') page = Page(num) if num == 0: blogs = [] else: blogs = yield from Blog.findAll(orderBy='created_at desc', limit=(page.offset, page.limit)) return { '__template__': 'blogs.html', 'page': page, 'blogs': blogs }
def api_comments(*, page='1'): page_index = get_page_index(page) num = yield from Comment.findNumber('count(id)') p = Page(num, page_index) if num == 0: return dict(page=p, comments=()) comments = yield from Comment.findAll(orderBy='created_at desc', limit=(p.offset, p.limit)) return dict(page=p, comments=comments)
def api_get_users(*, page='1'): page_index = get_page_index(page) num = yield from User.findNumber('count(id)') p = Page(num, page_index) if num == 0: return dict(page=p, users=()) users = yield from User.findAll(orderBy='created_at desc', limit=(p.offset, p.limit)) for u in users: u.passwd = '******' return dict(page=p, users=users)
def api_blogs(*, page='1'): page_index = get_page_index(page) num = yield from Blog.findNumber('count(id)') p = Page(num, page_index) if num == 0: return dict(page=p, blogs=()) blogs = yield from Blog.findAll(orderBy='created_at desc', limit=(p.offset, p.limit)) return dict(page=p, blogs=blogs)
def api_get_users(*, page='1'): page_index = get_page_index(page) num = await User.findNumber('count(id)') p = Page(num, page_index) if num == 0: return dict(page=p, users=()) users = await User.findAll(orderBy='created_at desc', limit=(p.offset, p.limit)) for u in users: u.password = '******' return dict(page=p, users=users)
def api_blogs(*, page='1'): page_index = get_page_index(page) num = await Blog.findNumber('count(id)') p = Page(num, page_index) if num == 0: return dict(page=p, blogs=()) blogs = await Blog.findAll(orderBy='created_at desc', limit=(p.offset, p.limit)) return dict(page=p, blogs=blogs)
def api_comments(*, page='1'): page_index = get_page_index(page) num = await Comment.findNumber('count(id)') p = Page(num, page_index) if num == 0: return dict(page=p, comments=()) comments = await Comment.findAll(orderBy='created_at desc', limit=(p.offset, p.limit)) return dict(page=p, comments=comments)
def index(*, page = '1'): page_index = get_page_index(page) num = await Blog.findNumber('count(id)') page = Page(num, page_index) if num == 0: blogs = [] else: blogs = await Blog.findAll(orderBy = 'created_at desc', limit = (page.offset, page.limit)) return { '__template__' : 'blogs.html', 'page' : page, 'blogs' : blogs }
def api_comments(*, page = '1'): ''' ??????, ????manage_comments.html. ''' page_index = get_page_index(page) num = await Comment.findNumber('count(id)') p = Page(num, page_index) if num == 0: return dict(page = p, comments = ()) comments = await Comment.findAll(orderBy = 'created_at desc', limit = (p.offset, p.limit)) return dict(page = p, comments = comments)
def api_get_users(*, page = '1'): ''' ?????????. ''' page_index = get_page_index(page) num = await User.findNumber('count(id)') p = Page(num, page_index) if num == 0: return dict(page = p, users = ()) users = await User.findAll(orderBy = 'created_at desc', limit = (p.offset, p.limit)) for u in users: u.passwd = '******' return dict(page = p, users = users)
def api_blogs(*, page = '1'): ''' ????????, ????manage_blogs.html. ''' page_index = get_page_index(page) num = await Blog.findNumber('count(id)') p = Page(num, page_index) if num == 0: return dict(page = p, blogs = ()) blogs = await Blog.findAll(orderby = 'created_at desc', limit = (p.offset, p.limit)) return dict(page = p, blogs = blogs)