2023-12-29 20:11:07 -05:00
|
|
|
import mongoose, { PopulatedDoc, Model, model } from "mongoose";
|
2023-09-25 19:26:13 -04:00
|
|
|
|
2023-12-20 17:23:31 -05:00
|
|
|
import { IBand } from "@models/band";
|
|
|
|
import { IUser } from "@models/user";
|
2023-09-25 19:26:13 -04:00
|
|
|
import SequenceFactory from "mongoose-sequence";
|
2023-12-20 17:23:31 -05:00
|
|
|
import { hasMigrated } from "@dbconfig";
|
2023-09-25 19:26:13 -04:00
|
|
|
|
|
|
|
const AutoIncrement = SequenceFactory(mongoose);
|
|
|
|
|
|
|
|
export interface IFicmas {
|
|
|
|
_id: number;
|
|
|
|
kink: string;
|
2023-12-29 19:06:55 -05:00
|
|
|
year: number;
|
|
|
|
bands: PopulatedDoc<IBand>[];
|
2023-09-25 19:26:13 -04:00
|
|
|
relationship: string;
|
2023-12-29 19:06:55 -05:00
|
|
|
wisher: PopulatedDoc<IUser>;
|
2023-09-25 19:26:13 -04:00
|
|
|
anniversary: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const FicmasSchema = new mongoose.Schema<IFicmas>({
|
|
|
|
_id: {
|
2023-10-03 01:15:29 -04:00
|
|
|
type: Number,
|
2023-09-25 19:26:13 -04:00
|
|
|
},
|
|
|
|
kink: {
|
2023-10-03 01:15:29 -04:00
|
|
|
type: String,
|
2023-09-25 19:26:13 -04:00
|
|
|
},
|
2023-12-29 19:06:55 -05:00
|
|
|
year: { type: Number },
|
2023-10-03 01:15:29 -04:00
|
|
|
bands: [
|
|
|
|
{
|
|
|
|
type: Number,
|
|
|
|
ref: "Band",
|
|
|
|
},
|
|
|
|
],
|
2023-09-25 19:26:13 -04:00
|
|
|
relationship: { type: String },
|
|
|
|
wisher: {
|
|
|
|
type: Number,
|
2023-10-03 01:15:29 -04:00
|
|
|
ref: "User",
|
2023-09-25 19:26:13 -04:00
|
|
|
},
|
|
|
|
anniversary: {
|
|
|
|
type: Boolean,
|
2023-10-03 01:15:29 -04:00
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
});
|
2023-09-25 19:26:13 -04:00
|
|
|
|
2023-12-29 20:11:07 -05:00
|
|
|
hasMigrated && !mongoose.models.Ficmas && FicmasSchema.plugin(AutoIncrement, { id: "ficmas_wishes", inc_field: "_id" });
|
2023-09-25 19:26:13 -04:00
|
|
|
|
2023-12-29 20:11:07 -05:00
|
|
|
export const Ficmas: Model<IFicmas> = mongoose.models.Ficmas || model("Ficmas", FicmasSchema, "ficmas_wishes");
|