Files
Checkmate/Server/models/Monitor.js
T

63 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-05-10 13:36:04 -07:00
const mongoose = require("mongoose");
2024-08-30 13:03:59 -07:00
const Notification = require("./Notification");
2024-05-10 13:36:04 -07:00
const MonitorSchema = mongoose.Schema(
{
userId: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
immutable: true,
2024-08-26 19:15:01 -07:00
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,
2024-09-03 16:01:24 -07:00
default: undefined,
},
type: {
type: String,
required: true,
2024-07-24 10:42:38 -07:00
enum: ["http", "ping", "pagespeed"],
},
url: {
type: String,
required: true,
},
isActive: {
type: Boolean,
default: true,
},
interval: {
// in milliseconds
type: Number,
default: 60000,
},
uptimePercentage: {
type: Number,
2024-09-03 16:01:24 -07:00
default: undefined,
},
2024-08-30 13:03:59 -07:00
notifications: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Notification",
},
],
},
{
timestamps: true,
}
);
2024-05-10 13:36:04 -07:00
module.exports = mongoose.model("Monitor", MonitorSchema);