Skip to content

MongoQueryRunner.databaseConnection is declared with a wrong type #6453

@justin-lau

Description

@justin-lau

Issue type:

[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[x] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

MongoQueryRunner.databaseConnection has the type Db while it should actually be MongoClient.

Where databaseConnection is defined in src/driver/mongodb/MongoQueryRunner.ts:

    /**
     * Real database connection from a connection pool used to perform queries.
     */
    databaseConnection: Db;

    // -------------------------------------------------------------------------
    // Constructor
    // -------------------------------------------------------------------------

    constructor(connection: Connection, databaseConnection: Db) {
        this.connection = connection;
        this.databaseConnection = databaseConnection;
        this.broadcaster = new Broadcaster(this);
    }

Where it is created in src/driver/mongodb/MongoDriver.ts:

    connect(): Promise<void> {
        return new Promise<void>((ok, fail) => {
            this.mongodb.MongoClient.connect(
                this.buildConnectionUrl(),
                this.buildConnectionOptions(),
                (err: any, client: any) => {
                    if (err) return fail(err);

                    this.queryRunner = new MongoQueryRunner(this.connection, client);
                    ObjectUtils.assign(this.queryRunner, { manager: this.connection.manager });
                    ok();
                });
        });
    }

Reference to mongodb.MongoClient.connect:
https://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#~connectCallback

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions