Skip to content

Commit

Permalink
fix: mongodb@4 compatibility support (#8412)
Browse files Browse the repository at this point in the history
Add support for mongodb 4.2

Closes: 8146
  • Loading branch information
Corky3892 committed Dec 11, 2021
1 parent 90a8deb commit 531013b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/entity-manager/MongoEntityManager.ts
Expand Up @@ -683,7 +683,8 @@ export class MongoEntityManager extends EntityManager {
* Overrides cursor's toArray and next methods to convert results to entity automatically.
*/
protected applyEntityTransformationToCursor<Entity>(metadata: EntityMetadata, cursor: Cursor<Entity> | AggregationCursor<Entity>) {
const ParentCursor = PlatformTools.load("mongodb").Cursor;
// mongdb-3.7 exports Cursor, mongodb-4.2 exports FindCursor, provide support for both.
const ParentCursor = PlatformTools.load("mongodb").Cursor || PlatformTools.load("mongodb").FindCursor;
const queryRunner = this.mongoQueryRunner;
cursor.toArray = function (callback?: MongoCallback<Entity[]>) {
if (callback) {
Expand Down

0 comments on commit 531013b

Please sign in to comment.