박권수

fix. db update and modify error fix

...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
2 const Hub = require('../../models/hub'); 2 const Hub = require('../../models/hub');
3 const Mqtt = require('../../lib/MqttModule'); 3 const Mqtt = require('../../lib/MqttModule');
4 4
5 -exports.hubRegister = async (ctx) => { 5 +exports.hubConnect = async (ctx) => {
6 const { host, port, hubId, topic } = ctx.request.body; 6 const { host, port, hubId, topic } = ctx.request.body;
7 7
8 - const hub = new Hub({ 8 + const hub = {
9 hubId, 9 hubId,
10 hosting : { 10 hosting : {
11 host, 11 host,
12 port 12 port
13 } 13 }
14 - }); 14 + };
15 15
16 await Hub.findOneAndUpdate({ 16 await Hub.findOneAndUpdate({
17 hubId 17 hubId
...@@ -24,4 +24,8 @@ exports.hubRegister = async (ctx) => { ...@@ -24,4 +24,8 @@ exports.hubRegister = async (ctx) => {
24 24
25 ctx.body = 'host :' + host; 25 ctx.body = 'host :' + host;
26 ctx.status = 200; 26 ctx.status = 200;
27 +}
28 +
29 +exports.hubDisconnect = async(ctx) => {
30 +
27 } 31 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -38,22 +38,22 @@ const getItemsList = async(queryUrl) => { ...@@ -38,22 +38,22 @@ const getItemsList = async(queryUrl) => {
38 } 38 }
39 39
40 //itemArray에 있는 모든 data를 MongoDB의 SMB collections에 저장함 40 //itemArray에 있는 모든 data를 MongoDB의 SMB collections에 저장함
41 -const exportJsonData = async(itemList) => { 41 +const exportJsonData = (itemList) => {
42 itemList.forEach(item => { 42 itemList.forEach(item => {
43 - const medicine = new Medicine({ 43 + const medicineId = item.itemSeq;
44 - medicineId : item.itemSeq, 44 + const medicineInfo = {
45 name : item.itemName, 45 name : item.itemName,
46 company : item.entpName, 46 company : item.entpName,
47 target : item.efcyQesitm, 47 target : item.efcyQesitm,
48 dosage : item.useMethodQesitm, 48 dosage : item.useMethodQesitm,
49 warn : item.atpnWarnQesitm + '\n\n' + item.atpnQesitm, 49 warn : item.atpnWarnQesitm + '\n\n' + item.atpnQesitm,
50 antiEffect : item.seQesitm 50 antiEffect : item.seQesitm
51 - }) 51 + };
52 52
53 Medicine.findOneAndUpdate({ 53 Medicine.findOneAndUpdate({
54 - medicineId : medicine.medicineId 54 + medicineId
55 - }, medicine, { 55 + }, medicineInfo, {
56 upsert : true 56 upsert : true
57 - }) 57 + }).exec();
58 }) 58 })
59 } 59 }
...\ No newline at end of file ...\ No newline at end of file
......