Files
smarthome/models/device.model.js
2024-03-18 00:08:48 +03:00

60 lines
903 B
JavaScript

const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const deviceLogSchema = new Schema({
remote_name: {
type: String
},
remote_type: {
type: String
},
operating_type: {
type: String // Toggle - Homekit Reset - Reset
},
log_time: {
type: Date
},
sensor_value: {
type: Number
},
battery_life: {
type: Number
}
});
const deviceSchema = new Schema({
device_name: {
type: String,
unique: true
},
device_type: {
type: String
},
manifactor: {
type: String
},
serial_number: {
type: String,
unique: true
},
model: {
type: String
},
firmware_version: {
type: String
},
device_ip_address: {
type: String,
unique: true
},
update_time: {
type: Date
},
device_log: [deviceLogSchema]
});
const Device = mongoose.model("Device", deviceSchema);
module.exports = Device;