fix
This commit is contained in:
parent
d14b83f3ef
commit
c22b40abb7
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -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) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user