import mongoose, {Schema, PopulatedDoc, Document, Model} from "mongoose"; import { IUser } from "../../models/user"; import SequenceFactory from "mongoose-sequence"; import { hasMigrated } from "../../lib/dbconfig"; const AutoIncrement = SequenceFactory(mongoose); export interface IBiffno { _id: number; title: string; description: string; excerpt: string; bands: number[]; tags: string[]; wordcount: number; genre: string; cover: string; year: number; author: PopulatedDoc } const biffnoschema = new mongoose.Schema({ _id: { type: Number }, title: { type: String, default: "" }, description: { type: String, default: "" }, excerpt: { type: String, default: "" }, bands: [{ type: Number, ref: "Band" }], tags: [{ type: String }], wordcount: { type: Number, default: 0 }, genre: { type: String }, cover: { type: String, default: "" }, year: { type: Number, default: 0 }, author: { type: Number, ref: "User" } }); hasMigrated && biffnoschema.plugin(AutoIncrement, {start_seq: 1, id: "bif_id"}); export const Biffno: Model = /* mongoose.models.Biffno || */ mongoose.model('Biffno', biffnoschema, 'biffno');