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

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

Open
UzverNumber47 opened this issue May 3, 2017 · 4 comments
Open

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

UzverNumber47 opened this issue May 3, 2017 · 4 comments

Comments

@UzverNumber47
Copy link

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

@pitchan
Copy link

pitchan commented Nov 17, 2017

Same here but seems the project is not updated anymore

@ihr-it-projekt
Copy link

i have the same issue... there are any solutions or forks for it?

@marcotuna
Copy link

marcotuna commented May 1, 2018

I've created a pull request that solves that issue #18

@israelglar
Copy link

Nice catch! I was searching what was causing this for some time now. Hope this changes is pushed soon

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants