Skip to content

MongoDB ConnectionManager doesn't select given database, creates new database "test" instead #6900

@C0dekid

Description

@C0dekid

Issue type:

[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:

[ ] latest
[ ] @next
[ x] ^0.2.28 (or put your version here)

Steps to reproduce or a small repository showing the problem:

This happens when I create a new connection, fill in the options including database as key.

const database = "tsbot";
const connectionManager: ConnectionManager = new ConnectionManager();
connectionManager.create({
    type: "mongodb",
    database: database, // returns "tsbots", gets ignored when you insert a document
    name: database,
    url: "mongo://user:pass@ip:port",
    useUnifiedTopology: true,
    useNewUrlParser: true,
    entities: [
        Warns
    ]
});

export default connectionManager;

The key database gets ignored when I insert a document. A new database test is created automatically instead. I tried using the URL mongodb://user:pass@ip:port/database, but that is returning Authentication Failed error, leaving that away in the URL establishes a fine connection.

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