-
Couldn't load subscription status.
- Fork 109
Description
arangojs 7.0.1
arangodb 3.6.5
typescript 4.0.2
When running the following using a db instance:
const query = aql`FOR i IN [] RETURN i`;
const cursor = await db.query(query, { count: true });
console.log(cursor.count);
await cursor.forEach((value: any) => { console.log(value); });
The console output is:
0
undefined
It seems the forEach callback is called once although the count is 0. IMHO this should not happen and the console output should read 0 only. Note that in the previous version (6.x.x), the each callback was not called.
The forEach method of the ArrayCursor looks at this.hasMore || Boolean(this._batches.length) to execute the callback. The use of the non-null assertion operator on the value seems somewhat misleading as value returned is undefined. Not sure why the _batches.length equals 1...