UNPKG

955 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const mongoose = require("mongoose");
4const sourceSchema = new mongoose.Schema({
5 Endpoint: { type: String, unique: true },
6 Interval: { type: Number, default: 60 * 1000 },
7 IsActive: { type: Boolean, default: false },
8 Thresholds: [
9 {
10 Name: { type: String },
11 Formula: { type: String },
12 Message: { type: String },
13 Type: { type: String, enum: ["goal", "critical"], default: "critical" },
14 ComputedFormula: { type: String }
15 }
16 ]
17}, { timestamps: true });
18/**
19 * pre save source middleware.
20 */
21sourceSchema.pre("save", function save(next) {
22 const source = this;
23 if (!source.Thresholds)
24 source.Thresholds = [];
25 next();
26});
27const Source = mongoose.model("Source", sourceSchema);
28exports.Source = Source;
29//# sourceMappingURL=source.model.js.map
\No newline at end of file