refactor(db/models): remove existence guard/check from models
This commit is contained in:
parent
bb1f410d88
commit
9dbf0548d7
@ -1,4 +1,4 @@
|
|||||||
import mongoose, { connect, PopulatedDoc, Document, Model } from "mongoose";
|
import mongoose, { connect, Document, Model } from "mongoose";
|
||||||
const { Schema, model } = mongoose;
|
const { Schema, model } = mongoose;
|
||||||
import SequenceFactory from "mongoose-sequence";
|
import SequenceFactory from "mongoose-sequence";
|
||||||
import { hasMigrated } from "~/lib/dbconfig";
|
import { hasMigrated } from "~/lib/dbconfig";
|
||||||
|
@ -67,7 +67,8 @@ const biffnoschema = new mongoose.Schema<IBiffno>({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
hasMigrated && !mongoose.models.Biffno;
|
hasMigrated &&
|
||||||
biffnoschema.plugin(AutoIncrement, { start_seq: 1, id: "bif_id" });
|
!mongoose.models.Biffno &&
|
||||||
|
biffnoschema.plugin(AutoIncrement, { start_seq: 1, id: "bif_id" });
|
||||||
export const Biffno: Model<IBiffno> =
|
export const Biffno: Model<IBiffno> =
|
||||||
mongoose.models.Biffno || mongoose.model("Biffno", biffnoschema, "biffno");
|
mongoose.models.Biffno || mongoose.model("Biffno", biffnoschema, "biffno");
|
||||||
|
@ -49,5 +49,5 @@ hasMigrated &&
|
|||||||
!mongoose.models.Challenge &&
|
!mongoose.models.Challenge &&
|
||||||
challengeSchema.plugin(AutoIncrement, { id: "challenges" });
|
challengeSchema.plugin(AutoIncrement, { id: "challenges" });
|
||||||
export const Challenge: Model<IChallenge> =
|
export const Challenge: Model<IChallenge> =
|
||||||
mongoose.models.Challenge ||
|
// mongoose.models.Challenge ||
|
||||||
mongoose.model("Challenge", challengeSchema, "challenges");
|
mongoose.model("Challenge", challengeSchema, "challenges");
|
||||||
|
@ -90,9 +90,7 @@ const StorySchema = new mongoose.Schema<IStory>({
|
|||||||
hasMigrated &&
|
hasMigrated &&
|
||||||
!mongoose.models.Story &&
|
!mongoose.models.Story &&
|
||||||
Chapter.plugin(AutoIncrement, { id: "chapterid", inc_field: "id" });
|
Chapter.plugin(AutoIncrement, { id: "chapterid", inc_field: "id" });
|
||||||
hasMigrated &&
|
hasMigrated && StorySchema.plugin(AutoIncrement, { id: "storyid" });
|
||||||
!mongoose.models.Story &&
|
|
||||||
StorySchema.plugin(AutoIncrement, { id: "storyid" });
|
|
||||||
export const Story: Model<IStory> =
|
export const Story: Model<IStory> =
|
||||||
/* mongoose.models.Story || */ mongoose.model(
|
/* mongoose.models.Story || */ mongoose.model(
|
||||||
"Story",
|
"Story",
|
||||||
|
Loading…
Reference in New Issue
Block a user