Esempio n. 1
0
    def get_list(self, page, per_page):
        """
        查看所有用户

        $input: @pagging
        $output:
            - @user
        """
        return db.pagging(r.table("user"), page, per_page)
Esempio n. 2
0
    def get_top(self, page, per_page, tag):
        """
        获取最新的文章,结果按时间倒序排序

        $input:
            $self@pagging: 分页
            tag?str&optional: 标签
        $output:
            - @article
        """
        q = r.table("article")
        if tag:
            q = q.filter(lambda x: tag in x["tags"])
        q = q.order_by(r.desc("date_modify"))
        return db.pagging(q, page, per_page)
Esempio n. 3
0
    def get_list(self, page, per_page, author, catalog, tag):
        """
        获取作者文章列表,结果按时间倒序排序

        $input:
            $self@pagging: 分页
            author?str: 作者
            catalog?str&optional: 目录
            tag?str&optional: 标签
        $output:
            - @article
        """
        q = r.table("article").get_all(author, index="author")
        if catalog:
            q = q.filter({"catalog": catalog})
        if tag:
            q = q.filter(lambda x: x["tags"].contains(tag))
        q = q.order_by(r.desc("date_modify"))
        return db.pagging(q, page, per_page)