Skip to content

the lb4 datasource can't create a database automatically in mongoDB #8809

Description

@Barnette-ao

Describe the bug

Desciption of the bug

when I want create a datasource to connect with mongoDB database,then I read the document ,I enter the lb4 datasource in the CLI. when I finish the creation of the datasource, the .datasource.ts file as follows:

const config = {
  name: 'db',
  connector: 'mongodb',
  url: 'mongodb://localhost:27017/testdb',
  host: 'loaclhost',
  port: 27017,
  user: '',
  password: '',
  database: 'testdb',
  useNewUrlParser: true
};

Expect

I expect after I finish the creation of the datasource,the testdb will automatically created in the MongoDB.

Actual

when I exeute the mongod.exe, and open the CLI, then
input:

show dbs

the output is :

3dcmsT     0.000GB
admin      0.000GB
config     0.000GB
local      0.000GB
vote_rule  0.001GB

there is no testdb as I expected!!!

what should I do to use lb4 datasource to connect the MongoDB server?

when I using loopback 3 to enter lb datasource ,the loopback will create the database automatically ,and I check the mongoDB,I also can see the new database when I define in the config.

but when I use loopback 4 to do the same thing,it is not work?!

It there angthing additional I should know to get my expection done ?

Logs

No response

Additional information

No response

Reproduction

https://codesandbox.io/s/nifty-wilson-4u0mdy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions