I'm trying to create a simple highland stream from a Mongo query
const connectionString = ...
const client = new MongoClient(connectionString);
const records = mongoClient
.db('mydb')
.collection('acollection')
.find({});
const res = await hi(records).tap(_log).collect().toPromise(Promise);
function _log(record) {
console.log(record);
return record;
}
This code works perfectly with mongodb (the npm package) < 4.0.0, but with Mongo >= 4.0.0 it prints an undefined over and over until its heap runs out.
I'm running MongoDb in docker, version image mongo:4.2.10
See this note from the mongodb 4.0.0 changelog
So the fix to the issue is to simply add
.stream()at the end of the mongo query: