18 lines
488 B
JavaScript
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);
|