Reputation: 29
I've tried to connect my Loopback application with MongoDb Atlas, but I'm having an error "TypeError: Cannot read property 'dbName' of null".
Below is what I've tried:
{
"db": {
"name": "db",
"connector": "mongodb"
},
"mongodb": {
"host": "",
"port": 0,
"url": "mongodb+srv://USER:[email protected]/test?retryWrites=true&w=majority",
"database": "DATABASENAME",
"password": "PASSWORD",
"name": "mongodb",
"user": "dbAdmin",
"useNewUrlParser": true,
"connector": "mongodb"
}
}
On every attempt to run "node ." , getting TypeError: Cannot read property 'dbName' of null
.
I've added my IP in the whitelisted IPs (MongoDB atlas)
Below is my model.config.json
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"User": {
"dataSource": "mongodb"
},
"AccessToken": {
"dataSource": "mongodb",
"public": false
},
"ACL": {
"dataSource": "mongodb",
"public": false
},
"RoleMapping": {
"dataSource": "mongodb",
"public": false,
"options": {
"strictObjectIDCoercion": true
}
},
"Role": {
"dataSource": "mongodb",
"public": false
}
}
PS: I'm using loopback 3x
Upvotes: 0
Views: 834
Reputation: 836
Don't put special character in your password, if you are using old mongodb
Upvotes: 0
Reputation: 29
Figured out that setting the property "useNewUrlParser": true
to false solved my issue. Still don't know why this was the root cause.
Upvotes: 1