Showing
2 changed files
with
9 additions
and
8 deletions
| ... | @@ -39,9 +39,7 @@ const bottleInfoUpdate = async(data) => { | ... | @@ -39,9 +39,7 @@ const bottleInfoUpdate = async(data) => { |
| 39 | if(isOpen === '1') { | 39 | if(isOpen === '1') { |
| 40 | await Bottle.findOneAndUpdate({ | 40 | await Bottle.findOneAndUpdate({ |
| 41 | bottleId | 41 | bottleId |
| 42 | - }, { recentOpen : openDate }, { | 42 | + }, { recentOpen : openDate }); |
| 43 | - new : true | ||
| 44 | - }); | ||
| 45 | } | 43 | } |
| 46 | 44 | ||
| 47 | await Bottle.findOneAndUpdate({ | 45 | await Bottle.findOneAndUpdate({ |
| ... | @@ -50,12 +48,12 @@ const bottleInfoUpdate = async(data) => { | ... | @@ -50,12 +48,12 @@ const bottleInfoUpdate = async(data) => { |
| 50 | temperature, | 48 | temperature, |
| 51 | humidity, | 49 | humidity, |
| 52 | balance | 50 | balance |
| 53 | - }, { new : true }); | 51 | + }); |
| 54 | } | 52 | } |
| 55 | 53 | ||
| 56 | //해당 MQTT Broker(client)에 bottleId의 정보에 관한 topic과 message를 리턴한다. | 54 | //해당 MQTT Broker(client)에 bottleId의 정보에 관한 topic과 message를 리턴한다. |
| 57 | const transPublishingTopicAndMessage = async(bottleId) => { | 55 | const transPublishingTopicAndMessage = async(bottleId) => { |
| 58 | - const topic = 'bottle/'.concat(bottleId) + '/stb'; | 56 | + const topic = 'bottle/' + bottleId + '/stb'; |
| 59 | 57 | ||
| 60 | const bottle = await Bottle.findByBottleId(bottleId); | 58 | const bottle = await Bottle.findByBottleId(bottleId); |
| 61 | const recentOpen = await bottle.getRecentOpenDate(); | 59 | const recentOpen = await bottle.getRecentOpenDate(); |
| ... | @@ -65,7 +63,7 @@ const transPublishingTopicAndMessage = async(bottleId) => { | ... | @@ -65,7 +63,7 @@ const transPublishingTopicAndMessage = async(bottleId) => { |
| 65 | return { | 63 | return { |
| 66 | topic, | 64 | topic, |
| 67 | message | 65 | message |
| 68 | - } | 66 | + }; |
| 69 | } | 67 | } |
| 70 | 68 | ||
| 71 | //날짜를 yymmdd로 변환해주는 함수 | 69 | //날짜를 yymmdd로 변환해주는 함수 | ... | ... |
| ... | @@ -39,6 +39,9 @@ exports.mqttOff = (hosting) => { | ... | @@ -39,6 +39,9 @@ exports.mqttOff = (hosting) => { |
| 39 | && client.options.host === hosting.host | 39 | && client.options.host === hosting.host |
| 40 | && client.options.port === hosting.port) | 40 | && client.options.port === hosting.port) |
| 41 | }); | 41 | }); |
| 42 | - clientList[filterIndex].end(); | 42 | + |
| 43 | - clientList.splice(filterIndex, 1); | 43 | + if(filterIndex !== -1) { |
| 44 | + clientList[filterIndex].end(); | ||
| 45 | + clientList.splice(filterIndex, 1); | ||
| 46 | + } | ||
| 44 | } | 47 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment