Move db models to db folder

This commit is contained in:
Alex Holliday committed 2024-10-01 10:01:25 +08:00
1 parent 34389d4878
commit 6c598b976f
29 files changed
+31 -30

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
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);