refactor(db/models): remove existence guard/check from models

This commit is contained in:
parent bb1f410d88
commit 9dbf0548d7
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C
4 changed files with 6 additions and 7 deletions

@ -1,4 +1,4 @@
import mongoose, { connect, PopulatedDoc, Document, Model } from "mongoose";
import mongoose, { connect, Document, Model } from "mongoose";
const { Schema, model } = mongoose;
import SequenceFactory from "mongoose-sequence";
import { hasMigrated } from "~/lib/dbconfig";

@ -67,7 +67,8 @@ const biffnoschema = new mongoose.Schema<IBiffno>({
},
});
hasMigrated && !mongoose.models.Biffno;
biffnoschema.plugin(AutoIncrement, { start_seq: 1, id: "bif_id" });
hasMigrated &&
!mongoose.models.Biffno &&
biffnoschema.plugin(AutoIncrement, { start_seq: 1, id: "bif_id" });
export const Biffno: Model<IBiffno> =
mongoose.models.Biffno || mongoose.model("Biffno", biffnoschema, "biffno");

@ -49,5 +49,5 @@ hasMigrated &&
!mongoose.models.Challenge &&
challengeSchema.plugin(AutoIncrement, { id: "challenges" });
export const Challenge: Model<IChallenge> =
mongoose.models.Challenge ||
// mongoose.models.Challenge ||
mongoose.model("Challenge", challengeSchema, "challenges");

@ -90,9 +90,7 @@ const StorySchema = new mongoose.Schema<IStory>({
hasMigrated &&
!mongoose.models.Story &&
Chapter.plugin(AutoIncrement, { id: "chapterid", inc_field: "id" });
hasMigrated &&
!mongoose.models.Story &&
StorySchema.plugin(AutoIncrement, { id: "storyid" });
hasMigrated && StorySchema.plugin(AutoIncrement, { id: "storyid" });
export const Story: Model<IStory> =
/* mongoose.models.Story || */ mongoose.model(
"Story",