Refactor models to extend a base check model
This commit is contained in:
1 parent
6e9e5e8033
commit
a7c00e9383
3 files changed
+71
-108
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import mongoose from "mongoose";
|
||||
import { BaseCheckSchema } from "./Check.js";
|
||||
import logger from "../../utils/logger.js";
|
||||
import { time } from "console";
|
||||
const AuditSchema = mongoose.Schema({
|
||||
id: { type: String, required: true },
|
||||
title: { type: String, required: true },
|
||||
@@ -46,15 +48,7 @@ const AuditsSchema = mongoose.Schema({
|
||||
|
||||
const PageSpeedCheck = mongoose.Schema(
|
||||
{
|
||||
monitorId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: "Monitor",
|
||||
immutable: true,
|
||||
},
|
||||
status: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
},
|
||||
...BaseCheckSchema.obj,
|
||||
accessibility: {
|
||||
type: Number,
|
||||
required: true,
|
||||
@@ -76,9 +70,7 @@ const PageSpeedCheck = mongoose.Schema(
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
}
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -112,4 +104,6 @@ PageSpeedCheck.pre("save", async function (next) {
|
||||
}
|
||||
});
|
||||
|
||||
PageSpeedCheck.index({ createdAt: 1 });
|
||||
|
||||
export default mongoose.model("PageSpeedCheck", PageSpeedCheck);
|
||||
Reference in new issue
Block a user