2023-12-29 20:11:07 -05:00
|
|
|
import mongoose, { Model } from "mongoose";
|
2023-10-03 01:22:43 -04:00
|
|
|
const { Schema, model } = mongoose;
|
2023-09-25 19:41:32 -04:00
|
|
|
import SequenceFactory from "mongoose-sequence";
|
2023-12-20 17:23:31 -05:00
|
|
|
import { hasMigrated } from "@dbconfig";
|
2023-09-25 19:41:32 -04:00
|
|
|
|
|
|
|
const AutoIncrement = SequenceFactory(mongoose);
|
|
|
|
|
|
|
|
export interface IBand {
|
|
|
|
_id: number;
|
|
|
|
name: string;
|
|
|
|
locked: boolean;
|
2023-10-03 01:22:43 -04:00
|
|
|
characters: string[];
|
2023-09-25 19:41:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const BandSchema = new mongoose.Schema<IBand>({
|
|
|
|
_id: {
|
2023-10-03 01:22:43 -04:00
|
|
|
type: Number,
|
2023-09-25 19:41:32 -04:00
|
|
|
},
|
|
|
|
name: {
|
2023-10-03 01:22:43 -04:00
|
|
|
type: String,
|
2023-09-25 19:41:32 -04:00
|
|
|
},
|
|
|
|
locked: {
|
|
|
|
type: Boolean,
|
2023-10-03 01:22:43 -04:00
|
|
|
default: false,
|
2023-09-25 19:41:32 -04:00
|
|
|
},
|
2023-10-03 01:22:43 -04:00
|
|
|
characters: [
|
|
|
|
{
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
2023-09-25 19:41:32 -04:00
|
|
|
|
2023-12-29 20:11:07 -05:00
|
|
|
hasMigrated && !mongoose.models.Band && BandSchema.plugin(AutoIncrement, { id: "band" });
|
|
|
|
export const Band: Model<IBand> = /* mongoose.models.Band || */ model<IBand>("Band", BandSchema, "bands");
|