Migrating to fastapi-pagination
This commit is contained in:
@@ -3,8 +3,8 @@ from beanie.odm.operators.find.comparison import In
|
||||
from beanie.operators import And, RegEx, Eq
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Depends
|
||||
from fastapi_paginate import Page, Params, add_pagination
|
||||
from fastapi_paginate.ext.motor import paginate
|
||||
from fastapi_pagination import Page, Params, add_pagination
|
||||
from fastapi_pagination.ext.beanie import paginate
|
||||
|
||||
from ..user.manager import get_current_user, get_current_superuser
|
||||
|
||||
@@ -79,8 +79,7 @@ def get_crud_router(model, model_create, model_read, model_update):
|
||||
sort = parse_sort(sort_by)
|
||||
query = parse_query(query, model_read)
|
||||
|
||||
collection = model.get_motor_collection()
|
||||
items = paginate(collection, query, Params(**{'size': size, 'page': page}), sort=sort)
|
||||
items = paginate(model.find(query), Params(**{'size': size, 'page': page}))
|
||||
return await items
|
||||
|
||||
@router.put("/{id}", response_description="{} record updated".format(model.__name__))
|
||||
|
||||
Reference in New Issue
Block a user