File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Original file line number Diff line number Diff line change 2
2
"api" : {
3
3
"prefix" : " freenitapi" ,
4
4
"body" : [
5
- " from typing import List" ,
6
- " " ,
7
- " import ormar" ,
8
5
" import ormar.exceptions" ,
9
- " from fastapi import HTTPException" ,
6
+ " from fastapi import Header, HTTPException" ,
10
7
" from freenit.api.router import route" ,
8
+ " from freenit.models.pagination import Page, paginate" ,
11
9
" " ,
12
10
" from ..models.${1} import ${1/(.*)/${1:/capitalize}/}, ${1/(.*)/${1:/capitalize}/}Optional" ,
13
11
" " ,
17
15
" @route(\" /${1}s\" , tags=tags)" ,
18
16
" class ${1/(.*)/${1:/capitalize}/}ListAPI:" ,
19
17
" @staticmethod" ,
20
- " async def get() -> List[${1/(.*)/${1:/capitalize}/}]:" ,
21
- " return await ${1/(.*)/${1:/capitalize}/}.objects.all()" ,
18
+ " async def get(" ,
19
+ " page: int = Header(default=1)," ,
20
+ " perpage: int = Header(default=10)," ,
21
+ " ) -> Page[${1/(.*)/${1:/capitalize}/}]:" ,
22
+ " return await paginate(${1/(.*)/${1:/capitalize}/}.objects, page, perpage)" ,
22
23
" " ,
23
24
" @staticmethod" ,
24
25
" async def post(${1}: ${1/(.*)/${1:/capitalize}/}) -> ${1/(.*)/${1:/capitalize}/}:" ,
You can’t perform that action at this time.
0 commit comments