more work!
This commit is contained in:
@ -1,45 +0,0 @@
|
||||
'use strict';
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require("../nySql.js")
|
||||
|
||||
const adminUserModel = sequelize.define('adminusers', {
|
||||
// Model attributes are defined here
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
primaryKey: true
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
username: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 50
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
password: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
lastLogin: {
|
||||
type: DataTypes.timestamps,
|
||||
allowNull: true,
|
||||
},
|
||||
jobTitle: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
}
|
||||
},{
|
||||
timestamps: false, // Disable automatic timestamps
|
||||
});
|
||||
|
||||
module.exports = { adminUserModel }
|
@ -3,7 +3,7 @@ const { Sequelize, DataTypes } = require("sequelize");
|
||||
const { sequelize } = require("../mySQL");
|
||||
|
||||
|
||||
sequelize.sync();
|
||||
//sequelize.sync();
|
||||
const api_log_Model = sequelize.define("api-logs",{
|
||||
// Model attributes are defined here
|
||||
id: {
|
||||
|
@ -2,7 +2,7 @@
|
||||
const { Sequelize, DataTypes } = require("sequelize");
|
||||
const { sequelize } = require("../mySQL");
|
||||
|
||||
sequelize.sync();
|
||||
//sequelize.sync();
|
||||
const locationModel = sequelize.define(
|
||||
"location",
|
||||
{
|
||||
|
54
Database/model/sensorDataModel.js
Normal file
54
Database/model/sensorDataModel.js
Normal file
@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
const { Sequelize, DataTypes } = require("sequelize");
|
||||
const { sequelize } = require("../mySQL");
|
||||
const { locationModel } = require("./locationModel");
|
||||
const { sensorModel } = require("./sensorModel");
|
||||
|
||||
//sequelize.sync();
|
||||
const sensorDataModel = sequelize.define("sensorData",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
id_sensor: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
length: 100,
|
||||
//FK
|
||||
references: {
|
||||
model: sensorModel,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
id_location: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
length: 100,
|
||||
//FK
|
||||
references: {
|
||||
model: locationModel,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
Sensordata: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: false,
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: true,
|
||||
},
|
||||
updatedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = { sensorDataModel };
|
54
Database/model/sensorModel.js
Normal file
54
Database/model/sensorModel.js
Normal file
@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
const { Sequelize, DataTypes } = require("sequelize");
|
||||
const { sequelize } = require("../mySQL");
|
||||
const { locationModel } = require("./locationModel");
|
||||
|
||||
//sequelize.sync();
|
||||
const sensorModel = sequelize.define("sensors",
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
sensortype: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 10,
|
||||
},
|
||||
added_by: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
length: 10,
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 100,
|
||||
},
|
||||
location: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
length: 100,
|
||||
//one to many relationship
|
||||
references: {
|
||||
model: locationModel,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: true,
|
||||
},
|
||||
updatedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = { sensorModel };
|
@ -1,40 +0,0 @@
|
||||
'use strict';
|
||||
const { Sequelize, DataTypes } = require('sequelize');
|
||||
const { sequelize } = require("../mySql.js");
|
||||
|
||||
const userModel = sequelize.define('users', {
|
||||
// Model attributes are defined here
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
primaryKey: true
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
username: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 50
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
password: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
length: 255
|
||||
},
|
||||
lastLogin: {
|
||||
type: DataTypes.timestamps,
|
||||
allowNull: true,
|
||||
}
|
||||
},{
|
||||
timestamps: false, // Disable automatic timestamps
|
||||
});
|
||||
|
||||
module.exports = { userModel }
|
Reference in New Issue
Block a user