Files
Checkmate/Server/models/Monitor.js
Alex Holliday 9110e0b6cc restore monitor
2024-09-03 16:01:24 -07:00

64 lines
1.1 KiB
JavaScript

const mongoose = require("mongoose");
const Notification = require("./Notification");
const MonitorSchema = mongoose.Schema(
{
userId: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
immutable: true,
required: true,
},
teamId: {
type: mongoose.Schema.Types.ObjectId,
ref: "Team",
immutable: true,
required: true,
},
name: {
type: String,
required: true,
},
description: {
type: String,
},
status: {
type: Boolean,
default: undefined,
},
type: {
type: String,
required: true,
enum: ["http", "ping", "pagespeed"],
},
url: {
type: String,
required: true,
},
isActive: {
type: Boolean,
default: true,
},
interval: {
// in milliseconds
type: Number,
default: 60000,
},
uptimePercentage: {
type: Number,
default: undefined,
},
notifications: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Notification",
},
],
},
{
timestamps: true,
}
);
module.exports = mongoose.model("Monitor", MonitorSchema);