loopback-component-storage-mongo icon indicating copy to clipboard operation
loopback-component-storage-mongo copied to clipboard

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

Open UzverNumber47 opened this issue 7 years ago • 4 comments

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

UzverNumber47 avatar May 03 '17 11:05 UzverNumber47

Same here but seems the project is not updated anymore

pitchan avatar Nov 17 '17 14:11 pitchan

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

ihr-it-projekt avatar Apr 27 '18 09:04 ihr-it-projekt

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

marcotuna avatar May 01 '18 16:05 marcotuna

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

israelglar avatar May 04 '18 13:05 israelglar