a
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
const { sequelize } = require("../../Database/mySql.js");
|
||||
const { IoTModel } = require("../../Database/model/IoTModel.js");
|
||||
const { locationModel } = require("../../Database/model/locationModel.js");
|
||||
const { sensorModel } = require("../../Database/model/sensorModel.js");
|
||||
const { sensorDataModel } = require("../../Database/model/sensorDataModel.js");
|
||||
@ -64,7 +63,7 @@ async function getSensor() {
|
||||
async function addSensor(sensorname, added_by, mac_address , description, location) {
|
||||
try {
|
||||
const sensor = await sensorModel.create({
|
||||
sensorname: sensorname,
|
||||
name: sensorname,
|
||||
added_by: added_by,
|
||||
mac_address: mac_address,
|
||||
description: description,
|
||||
@ -80,7 +79,7 @@ async function updateSensor(id, sensorname, added_by, mac_address ,description,
|
||||
//update by id
|
||||
const sensor = await sensorModel.update(
|
||||
{
|
||||
sensorname: sensorname,
|
||||
name: sensorname,
|
||||
added_by: added_by,
|
||||
mac_address: mac_address,
|
||||
description: description,
|
||||
@ -143,9 +142,9 @@ async function addSensorData(id , id_sensor , id_location , sensordata){
|
||||
}
|
||||
const sensorData = await sensorDataModel.create({
|
||||
id: id,
|
||||
id_sensor: id_sensor,
|
||||
id_location: id_location,
|
||||
sensordata: sensordata,
|
||||
sensorid: id_sensor,
|
||||
locationid: id_location,
|
||||
measurement: sensordata,
|
||||
});
|
||||
}catch(error){
|
||||
console.error(error);
|
||||
@ -157,9 +156,9 @@ async function updateSensorData(id, id_sensor, id_location, sensordata) {
|
||||
try {
|
||||
const sensorData = await sensorDataModel.update(
|
||||
{
|
||||
id_sensor: id_sensor,
|
||||
id_location: id_location,
|
||||
sensordata: sensordata,
|
||||
ensorid: id_sensor,
|
||||
locationid: id_location,
|
||||
measurement: sensordata,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
|
@ -1,27 +1,5 @@
|
||||
const { sequelize } = require("../../Database/mySql.js");
|
||||
const { IoTModel } = require("../../Database/model/IoTModel.js");
|
||||
const { api_log_Model } = require("../../Database/model/apiLog.js");
|
||||
|
||||
function insertData(data) {
|
||||
try {
|
||||
//const latestData = await IoTModel.create({
|
||||
IoTModel.create({
|
||||
psiData: data.psi,
|
||||
humidityData: data.humidity,
|
||||
o3Data: data.o3,
|
||||
no2Data: data.no2,
|
||||
so2Data: data.so2,
|
||||
coData: data.co,
|
||||
temperatureData: data.temperature,
|
||||
windspeedData: data.windspeed,
|
||||
currentTime: data.time,
|
||||
regionData: data.region,
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
const { api_log_Model } = require("../../Database/model/apiLogModel.js");
|
||||
|
||||
async function insertLogData(log){
|
||||
try{
|
||||
@ -43,7 +21,7 @@ async function insertLogData(log){
|
||||
|
||||
}
|
||||
|
||||
module.exports = { insertData , insertLogData };
|
||||
module.exports = { insertLogData };
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user