This commit is contained in:
newtbot
2024-01-05 19:42:02 +08:00
parent b978f07867
commit a9912d4ddc
17 changed files with 628 additions and 353 deletions

View File

@ -1,77 +0,0 @@
"use strict";
const { Sequelize, DataTypes } = require("sequelize");
const { sequelize } = require("../mySQL");
const IoTModel = sequelize.define("iot-data",{
id: {
type: DataTypes.INTEGER,
allowNull: true,
primaryKey: true,
},
psiData: {
type: DataTypes.STRING,
allowNull: false,
length: 8,
},
humidityData: {
type: DataTypes.STRING,
allowNull: false,
length: 8,
},
o3Data: {
type: DataTypes.STRING,
allowNull: false,
length: 8,
},
no2Data: {
type: DataTypes.STRING,
allowNull: false,
length: 8,
},
so2Data: {
type: DataTypes.STRING,
allowNull: false,
length: 8,
},
coData: {
type: DataTypes.STRING,
allowNull: false,
length: 8,
},
temperatureData: {
type: DataTypes.STRING,
allowNull: false,
length: 8,
},
windspeedData: {
type: DataTypes.STRING,
allowNull: false,
length: 8,
},
currentTime: {
type: DataTypes.STRING,
allowNull: false,
length: 20,
},
regionData: {
type: DataTypes.STRING,
allowNull: false,
length: 10,
},
createdAt: {
type: DataTypes.DATE,
allowNull: true,
},
updatedAt: {
type: DataTypes.DATE,
allowNull: true,
},
},
{
timestamps: true,
}
);
module.exports = { IoTModel };

View File

@ -5,7 +5,7 @@ const { locationModel } = require("./locationModel");
const { sensorModel } = require("./sensorModel");
const { isJson } = require("../../Web-Server/functions/validateData");
//sequelize.sync();
sequelize.sync();
const sensorDataModel = sequelize.define(
"sensorData",
{
@ -20,7 +20,7 @@ const sensorDataModel = sequelize.define(
notEmpty: true,
},
},
id_sensor: {
sensorid: {
type: DataTypes.INTEGER,
allowNull: false,
length: 100,
@ -34,7 +34,7 @@ const sensorDataModel = sequelize.define(
notEmpty: true,
},
},
id_location: {
locationid: {
type: DataTypes.INTEGER,
allowNull: false,
length: 100,
@ -48,7 +48,7 @@ const sensorDataModel = sequelize.define(
notEmpty: true,
},
},
sensordata: {
measurement: {
type: DataTypes.JSON,
allowNull: false,
validate: {

View File

@ -23,7 +23,7 @@ const sensorModel = sequelize.define(
isNumeric: true,
},
},
sensorname: {
name: {
type: DataTypes.STRING,
allowNull: false,
length: 10,
@ -79,7 +79,7 @@ const sensorModel = sequelize.define(
},
},
},
location: {
locationid: {
type: DataTypes.INTEGER,
allowNull: true,
length: 100,