1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const mongoose = require("mongoose");
|
4 | const 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 |
|
20 |
|
21 | sourceSchema.pre("save", function save(next) {
|
22 | const source = this;
|
23 | if (!source.Thresholds)
|
24 | source.Thresholds = [];
|
25 | next();
|
26 | });
|
27 | const Source = mongoose.model("Source", sourceSchema);
|
28 | exports.Source = Source;
|
29 |
|
\ | No newline at end of file |