import { IStory } from "."; import { hasMigrated } from "@dbconfig"; import mongoose, { Schema, Model } from "mongoose"; import SequenceFactory from "mongoose-sequence"; import { Chapter } from "./chapter"; const AutoIncrement = SequenceFactory(mongoose); export type IDraft = Omit; // 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");