I would like to do something like this.
function* iterateRecord() {
const db = yield MongoClient.connect('');
const collection = db.collection('');
const query = {}
const cursor = collection.find(query);
while (yield cursor.hasNext()) {
const bsonObject = yield cursor.next();
}
}
for(record of iterateRecord())
{
//do stuff
}
Now as you can see this will not work the db yield will be the first iteration of the for. So what I would like to do is only return the yield at the cursor.next.
Is this possible? I have tried a few things but i always get to the multiple yield that not part of the iteration.
thanks