fastapi-pagination icon indicating copy to clipboard operation
fastapi-pagination copied to clipboard

Beanie ODM support

Open TamiasSibiricus opened this issue 2 years ago • 5 comments

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

TamiasSibiricus avatar Jul 05 '22 14:07 TamiasSibiricus

Hi @TamiasSibiricus,

Do you have any plans to implement it?

uriyyo avatar Jul 24 '22 15:07 uriyyo

Hi @uriyyo

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

TamiasSibiricus avatar Jul 24 '22 15:07 TamiasSibiricus

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.

deejaypro avatar Sep 08 '22 18:09 deejaypro

Hi @TamiasSibiricus,

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

uriyyo avatar Sep 10 '22 10:09 uriyyo

Hi @deejaypro,

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

uriyyo avatar Sep 13 '22 07:09 uriyyo

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

syedhabib53 avatar Oct 15 '22 04:10 syedhabib53

@syedhabib53 I hope I will do it in one week

uriyyo avatar Oct 15 '22 08:10 uriyyo

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 avatar Nov 18 '22 12:11 marigan

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

marigan avatar Nov 18 '22 13:11 marigan

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

Rivosoa avatar Nov 27 '22 13:11 Rivosoa

Hi all,

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

uriyyo avatar Nov 27 '22 17:11 uriyyo