import { IStory } from "."; import { hasMigrated } from "@dbconfig"; import { IBand } from "@models/band"; import { IFicmas } from "@models/challenges/ficmas"; import { IChallenge } from "@models/challenges/gen"; import { IUser } from "@models/user"; import mongoose, { Schema, PopulatedDoc, Document, Model } from "mongoose"; import SequenceFactory from "mongoose-sequence"; import { Chapter } from "./chapter"; const AutoIncrement = SequenceFactory(mongoose); export type IDraft = Omit< IStory, "recs" | "favs" | "reviews" | "views" | "downloads" | "posted" >; // const Cha const DraftSchema = new Schema( { title: { type: String, }, _id: { type: Number, }, coAuthor: { type: Number, ref: "User", default: null, }, author: { type: Number, ref: "User", }, chapters: [Chapter], }, { timestamps: true }, ); hasMigrated && !mongoose.models.Draft && DraftSchema.plugin(AutoIncrement, { id: "drafts" }); export const Draft: Model = /* mongoose.models.Draft || */ mongoose.model("Draft", DraftSchema, "drafts");