medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
438 stars 206 forks source link

Add functionality of getting people as an iterator in cht-datasource #9238

Open sugat009 opened 1 month ago

sugat009 commented 1 month ago

Is your feature request related to a problem? Please describe.

This feature is part of a bigger feature of the creation of API endpoints for getting contacts by type. (#9193) The target of this feature is to have the functionality of getting people using cht-datasource as an AsyncIterator or something similar that can fetch data in batches.

Describe the solution you'd like

Person.v1.getAllAsync();

Describe alternatives you've considered

Additional context

jkuester commented 1 month ago

As noted here: https://github.com/medic/cht-core/issues/9237#issuecomment-2221081736

I think we should go for a function signature like:

const getAll = () => AsyncGenerator<Person.v1.Person, void>

Also, FTR, I have found this blog post to be very helpful in wrapping my mind around async interators/generators.