You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
3.2 KiB
104 lines
3.2 KiB
const mongoose = require("mongoose");
|
|
const moment = require('moment');
|
|
|
|
|
|
|
|
const Schema = mongoose.Schema;
|
|
const ObjectId = Schema.Types.ObjectId;
|
|
|
|
// Store a random password reset code
|
|
const code = Math.floor(100000 + Math.random() * 900000);
|
|
const RoleSchema = new Schema({ name: String });
|
|
// const tanksSchema = new mongoose.Schema({
|
|
// hardwareId: { type: String },
|
|
// hardwareId_type: { type: String },
|
|
// hardwareId_company: { type: String },
|
|
// customerId: { type: String, default: null },
|
|
// tankName: { type: String, default: null },
|
|
// blockName: { type: String, default: null },
|
|
// capacity: { type: String, default: "0" },
|
|
// typeOfWater: { type: String, default: null },
|
|
// waterlevel: { type: String, default: "0" },
|
|
// tankLocation: { type: String, default: null },
|
|
// motor_status: { type: String, default: 0 },
|
|
// connections: {
|
|
// source: { type: String},
|
|
// inputConnections: [{ inputConnections: String,input_type:String,motor_status: { type: String, default: "0" } }],
|
|
// outputConnections: [{ outputConnections: String,output_type:String }]
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
const tanksSchema = new mongoose.Schema({
|
|
hardwareId: { type: String },
|
|
hardwareId_type: { type: String },
|
|
hardwareId_company: { type: String },
|
|
customerId: { type: String, default: null },
|
|
tankName: { type: String, default: null },
|
|
blockName: { type: String, default: null },
|
|
capacity: { type: String, default: "0" },
|
|
typeOfWater: { type: String, default: null },
|
|
waterlevel: { type: String, default: "0" },
|
|
tankLocation: { type: String, default: null },
|
|
motor_status: { type: String, default: "0" },
|
|
waterlevel_at_midnight:{ type: String,default:"0" },
|
|
connections: {
|
|
source: { type: String },
|
|
inputConnections: [
|
|
{
|
|
inputConnections: { type: String },
|
|
input_type: { type: String },
|
|
inputismotor: { type: Boolean, },
|
|
motor_status: { type: String, default: "0" }
|
|
}
|
|
],
|
|
outputConnections: [
|
|
{
|
|
outputConnections: { type: String },
|
|
output_type: { type: String },
|
|
outputismotor: { type: Boolean, },
|
|
motor_status: { type: String, default: "0" }
|
|
}
|
|
]
|
|
}
|
|
});
|
|
|
|
|
|
|
|
const motordataSchema = new mongoose.Schema({
|
|
customerId: { type: String, default: null },
|
|
supplierTank: { type: String, default: null },
|
|
receiverTank: { type: String, default: null },
|
|
startTime: { type: String, default: null },
|
|
stopTime: { type: String, default: null },
|
|
supplier_type: { type: String, default: null },
|
|
receiver_type: { type: String, default: null },
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const IOttankSchema = new mongoose.Schema({
|
|
hardwareId: { type: String},
|
|
tankHeight: { type: String, required: true },
|
|
maxLevel: { type: String, required: true },
|
|
minLevel: { type: String, required: true },
|
|
date: { type: String, required: true },
|
|
time: { type: String, required: true },
|
|
mode: { type: Number, required: true }
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Tank = mongoose.model("Tank", tanksSchema);
|
|
const MotorData = mongoose.model("MotorData", motordataSchema);
|
|
const IotData = mongoose.model("IotData", IOttankSchema);
|
|
module.exports = {
|
|
Tank, MotorData,IotData
|
|
}
|