Skip to content
This repository was archived by the owner on Oct 27, 2020. It is now read-only.
This repository was archived by the owner on Oct 27, 2020. It is now read-only.

the options [connector,hostname, etc.] is not supported #13

@UzverNumber47

Description

@UzverNumber47

mongodb.connect method accepts 3 arguments url, options and callback. In the connect method of the module settings object is passed as options. So some of the fields are not supported by mongodb client.

Settings is something that loopback passes from datasources.[env].json when creating a datasource.
Maybe it's a good idea to pass settings.options instead of the entire object to mongodb.connect?
In datasources.[env].json:

"storage": {
    "name": "storage",
    "connector": "loopback-component-storage-mongo",
    "host": "127.0.0.1",
    "database": "test",
    "port": 27017,
    "options": {
       "mongoConnectionOption1": "value"
    }
  }
connect: (callback) ->
    self = @
    if @db
      process.nextTick ->
        if callback
          callback null, self.db
    else
      mongodb.MongoClient.connect @settings.url, @settings.options, (err, db) ->
        if not err
          debug 'Mongo connection established: ' + self.settings.url
          self.db = db
        if callback
          callback err, db

Annoying warning:
the options [connector] is not supported
the options [hostname] is not supported
the options [port] is not supported
the options [debug] is not supported
the options [url] is not supported

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions