55 lines
1.0 KiB
TypeScript
55 lines
1.0 KiB
TypeScript
import mongoose, {
|
|
Schema,
|
|
PopulatedDoc,
|
|
Document,
|
|
Model,
|
|
model,
|
|
} from "mongoose";
|
|
|
|
import { IBand } from "~/models/band";
|
|
import { IUser } from "~/models/user";
|
|
import SequenceFactory from "mongoose-sequence";
|
|
import { hasMigrated } from "~/lib/dbconfig";
|
|
|
|
const AutoIncrement = SequenceFactory(mongoose);
|
|
|
|
export interface IFicmas {
|
|
_id: number;
|
|
kink: string;
|
|
year: string;
|
|
bands: PopulatedDoc<IBand & Document>[];
|
|
relationship: string;
|
|
wisher: PopulatedDoc<IUser & Document>;
|
|
anniversary: boolean;
|
|
}
|
|
|
|
export const FicmasSchema = new mongoose.Schema<IFicmas>({
|
|
_id: {
|
|
type: Number,
|
|
},
|
|
kink: {
|
|
type: String,
|
|
},
|
|
year: { type: String },
|
|
bands: [
|
|
{
|
|
type: Number,
|
|
ref: "Band",
|
|
},
|
|
],
|
|
relationship: { type: String },
|
|
wisher: {
|
|
type: Number,
|
|
ref: "User",
|
|
},
|
|
anniversary: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
});
|
|
|
|
hasMigrated && FicmasSchema.plugin(AutoIncrement, { id: "ficmas_wishes" });
|
|
|
|
export const Ficmas: Model<IFicmas> =
|
|
mongoose.models.Ficmas || model("Ficmas", FicmasSchema, "ficmas_wishes");
|