uriyyo / fastapi-pagination

FastAPI pagination 📖
https://uriyyo-fastapi-pagination.netlify.app/
MIT License
1.17k stars 133 forks source link

Beanie ODM support #334

Closed TamiasSibiricus closed 1 year ago

TamiasSibiricus commented 2 years ago

Hi, I think it would be helpful to add Beanie ODM support for pagination. I'll prepare Pull request in next few days.

uriyyo commented 2 years ago

Hi @TamiasSibiricus,

Do you have any plans to implement it?

TamiasSibiricus commented 2 years ago

Hi @uriyyo

Yes.. Just do not complete tests for plugin before my vacation. Will create PR next week.

deejaypro commented 2 years ago

Hey,

i just wanted to ask, if you still have plans to create a PR for this? I would like to use this module with my existing Fast-Api+Beanie API.

uriyyo commented 2 years ago

Hi @TamiasSibiricus,

Sorry for bothering you. Do you still have plans to implement this integration?

uriyyo commented 2 years ago

Hi @deejaypro,

Beanie integration has been added and will be released in the next version.

syedhabib53 commented 2 years ago

@uriyyo When can we expect next release? We are using right now with git url. 🙄

uriyyo commented 2 years ago

@syedhabib53 I hope I will do it in one week

marigan commented 1 year ago

fetch_links feature is missing in this implementation unfortunately!

If you have a query where you are searching through nested links you have the have fetch_links=True in the very latest find_many in paginate

marigan commented 1 year ago

It can be done like this

async def paginate(
    query: Union[TDocument, FindMany[TDocument]],
    params: Optional[AbstractParams] = None,
    *,
    additional_data: AdditionalData = None,
    fetch_links: bool = False
) -> AbstractPage[TDocument]:
    params, raw_params = verify_params(params, "limit-offset")

    items = await query.find_many(limit=raw_params.limit, skip=raw_params.offset, fetch_links=fetch_links).to_list()
    total = await query.find({}, fetch_links=fetch_links).count()

    return create_page(items, total, params, **(additional_data or {}))

anyway there is a bug in beanie while the count won't work here roman-right/beanie#426

Rivosoa commented 1 year ago

Hi @uriyyo , may I know when you will release the version with Beanie support please?

uriyyo commented 1 year ago

Hi all,

New version 0.11.0 has been released. Now fastapi-pagination supports beanie.