I'm having a generator that, among other operations, queries a database, like
function* current(db) {
const items = await db.collection('...').find({ ... });
for (const item of items)
if (...) yield item;
}
which isn't valid syntax. Using promises and yielding from a then, isn't possible either.
What should I do then? How can I use asynchronous operation inside a generator?