refactor(db/models): change draft type to story type with omitted fields

This commit is contained in:
parent 9fe4d0c979
commit ad8be9d7fa
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -1,96 +1,42 @@
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 { IStory } from ".";
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";
import { Chapter } from "./chapter";
const AutoIncrement = SequenceFactory(mongoose);
export interface IDraft {
_id?: number,
title: string;
chaptertitle: string;
updatedAt: Date;
author: PopulatedDoc<IUser & Document>;
notes: string;
genre: string[];
bands: PopulatedDoc<IBand & Document>[];
characters: string[];
relationships: string[];
summary: string;
nsfw: boolean;
hidden: boolean;
loggedInOnly: boolean;
oneshot: boolean;
challenge: PopulatedDoc<IChallenge & Document>;
ficmas: PopulatedDoc<IFicmas & Document>;
}
export type IDraft = Omit<
IStory,
"recs" | "favs" | "reviews" | "views" | "downloads" | "posted"
>;
// const Cha
const DraftSchema = new Schema<IDraft>({
title: {
type: String
},
_id: {
type: Number
},
chaptertitle: {
type: String,
},
updatedAt: {
type: Date,
default: new Date()
_id: {
type: Number,
},
coAuthor: {
type: Number,
ref: "User",
default: null,
},
author: {
type: Number,
ref: "User"
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
}
})
chapters: [Chapter],
});
hasMigrated && DraftSchema.plugin(AutoIncrement, {id: "drafts"})
hasMigrated && DraftSchema.plugin(AutoIncrement, { id: "drafts" });
export const Draft: Model<IDraft> = /* mongoose.models.Draft || */ mongoose.model("Draft", DraftSchema, "drafts")
export const Draft: Model<IDraft> =
/* mongoose.models.Draft || */ mongoose.model("Draft", DraftSchema, "drafts");