This commit is contained in:
Wolfgang Hottgenroth 2018-05-14 15:24:51 +02:00
parent d14b83f3ef
commit c22b40abb7
Signed by: wn
GPG Key ID: B586EAFCDF2F65F4
2 changed files with 7 additions and 7 deletions

View File

@ -3,15 +3,15 @@
"brokerUser": "",
"brokerPass": "",
"brokerCa": "",
"mongoDbUrl": "mongodb://localhost/testdb",
"verbose": false,
"mongodbUrl": "mongodb://localhost/smarthome",
"verbose": true,
"instances": [
{
"instanceId": "testInstance",
"collection": "testcollection",
"topics": [ "topic1", "topic2", "topic3" ],
"encapsulate": false,
"parsePayload": false
"encapsulate": true,
"parsePayload": true
}
]
}

View File

@ -39,12 +39,12 @@ export default class MqttMongo extends Events.EventEmitter {
connectToDatabase() {
this.loginfo("About to connect to database")
Mongo.MongoClient.connect(this.options.database)
Mongo.MongoClient.connect(this.options.mongodbUrl)
.then(
(tmpDbHandle: Mongo.Db) => {
this.dbHandle = tmpDbHandle
this.dbReady = true;
this.loginfo("Database connected")
this.loginfo(`Database ${this.options.mongodbUrl} connected`)
this.dbHandle.on('reconnectFailed', (err : any) => { this.logwarn(`Error on database ${err}`) })
this.dbHandle.on('reconnect', () => {
this.loginfo("Reconnect on database")
@ -77,7 +77,7 @@ connectToDatabase() {
.then(
(r) => {
if (this.options.verbose) {
this.loginfo(`Successfully inserted into database ${JSON.stringify(msg.getMessage())}`)
this.loginfo(`Successfully inserted into database ${this.options.mongodbUrl}, ${this.options.collection}: ${JSON.stringify(msg.getMessage())}`)
}
},
(err) => {