import { hasMigrated } from "../../lib/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"; const AutoIncrement = SequenceFactory(mongoose); export interface IDraft { _id?: number, title: string; chaptertitle: string; updatedAt: Date; author: PopulatedDoc; notes: string; genre: string[]; bands: PopulatedDoc[]; characters: string[]; relationships: string[]; summary: string; nsfw: boolean; hidden: boolean; loggedInOnly: boolean; oneshot: boolean; challenge: PopulatedDoc; ficmas: PopulatedDoc; } const DraftSchema = new Schema({ title: { type: String }, _id: { type: Number }, chaptertitle: { type: String, }, updatedAt: { type: Date, default: new Date() }, author: { type: Number, ref: "User" }, notes: { type: String }, genre: [{ type: String }], bands: [{ type: Number, ref: "Band" }], characters: [{ type: String }], relationships: [{ type: String }], nsfw: { type: Boolean }, summary: { type: String }, hidden: { type: Boolean, default: false }, loggedInOnly: { type: Boolean }, oneshot: { type: Boolean, default: false }, challenge: { type: Number, ref: "Challenge", default: null }, ficmas: { type: Number, ref: "Ficmas", default: null } }) hasMigrated && DraftSchema.plugin(AutoIncrement, {id: "drafts"}) export const Draft: Model = /* mongoose.models.Draft || */ mongoose.model("Draft", DraftSchema, "drafts")