next/models/stories/chapter.ts

66 lines
988 B
TypeScript

import { Schema, PopulatedDoc, Document, Model } from "mongoose";
import { IBand } from "@models/band";
export interface IChapter {
title: string;
summary: string;
id?: number;
// index: number;
words?: number;
notes: string;
genre: string[];
bands: PopulatedDoc<IBand & Document>[];
characters: string[];
relationships: string[][];
nsfw: boolean;
loggedInOnly: boolean;
hidden: boolean;
posted?: Date;
}
export const Chapter = new Schema<IChapter>({
title: {
type: String,
default: "",
},
id: {
type: Number,
},
summary: {
type: String,
},
words: {
type: Number,
},
notes: {
type: String,
},
genre: [
{
type: String,
},
],
bands: [
{
type: Number,
ref: "Band",
},
],
characters: [{ type: String }],
relationships: [[{ type: String }]],
nsfw: {
type: Boolean,
},
loggedInOnly: {
type: Boolean,
default: true,
},
hidden: {
type: Boolean,
default: false,
},
posted: {
type: Date,
default: new Date(),
},
});