2023-10-03 01:15:29 -04:00
|
|
|
import mongoose, {
|
|
|
|
Schema,
|
|
|
|
PopulatedDoc,
|
|
|
|
Document,
|
|
|
|
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;
|
|
|
|
year: string;
|
|
|
|
bands: PopulatedDoc<IBand & Document>[];
|
|
|
|
relationship: string;
|
|
|
|
wisher: PopulatedDoc<IUser & Document>;
|
|
|
|
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
|
|
|
},
|
|
|
|
year: { type: String },
|
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-10-12 22:28:37 -04:00
|
|
|
hasMigrated &&
|
2023-12-29 18:05:18 -05:00
|
|
|
!mongoose.models.Ficmas &&
|
2023-10-12 22:28:37 -04:00
|
|
|
FicmasSchema.plugin(AutoIncrement, { id: "ficmas_wishes", inc_field: "_id" });
|
2023-09-25 19:26:13 -04:00
|
|
|
|
2023-10-03 01:15:29 -04:00
|
|
|
export const Ficmas: Model<IFicmas> =
|
|
|
|
mongoose.models.Ficmas || model("Ficmas", FicmasSchema, "ficmas_wishes");
|