farmcontrol-api/src/schemas/host.schema.js
2025-05-09 22:19:35 +01:00

18 lines
488 B
JavaScript

import mongoose from "mongoose";
const { Schema } = mongoose;
const hostSchema = new mongoose.Schema({
online: { required: true, type: Boolean },
hostId: { required: true, type: String },
connectedAt: { required: true, type: Date },
status: { type: { required: true, type: String } },
});
hostSchema.virtual("id").get(function () {
return this._id.toHexString();
});
hostSchema.set("toJSON", { virtuals: true });
export const hostModel = mongoose.model("Host", hostSchema);