2023-12-06 21:28:51 -05:00
|
|
|
import mongoose, { connect, Document, 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 18:05:18 -05:00
|
|
|
hasMigrated &&
|
|
|
|
!mongoose.models.Band &&
|
|
|
|
BandSchema.plugin(AutoIncrement, { id: "band" });
|
2023-10-03 01:22:43 -04:00
|
|
|
export const Band: Model<IBand> = /* mongoose.models.Band || */ model<IBand>(
|
|
|
|
"Band",
|
|
|
|
BandSchema,
|
|
|
|
"bands",
|
|
|
|
);
|