diff --git a/dbScheme.js b/dbScheme.js new file mode 100644 index 0000000..15305a3 --- /dev/null +++ b/dbScheme.js @@ -0,0 +1,9 @@ +const mongoose = require("mongoose"); +const dbSchema = new mongoose.Schema( + { + name: String, + status: String + }, + { timestamps: true } +); +module.exports = mongoose.model("dbSchema", dbSchema); diff --git a/index.js b/index.js index b6a70de..aadbcff 100644 --- a/index.js +++ b/index.js @@ -16,11 +16,11 @@ let interval = setInterval(() => { (async url => { const value_data = await getScript(url); console.log(value_data); - // const item = new dbSchema({ - // name: value_data.split(",")[0], - // value: value_data.split(",")[1] - // }); - // await item.save(); + const item = new dbSchema({ + name: value_data.Sensors[0].TaskName, + status: value_data.Sensors[0].Switch + }); + await item.save(); })("http://localhost:3000/chillroom-server?ip=192.168.8.107"); }, 5000);