diff --git a/models/challenges/biffno.ts b/models/challenges/biffno.ts new file mode 100644 index 0000000..4ccd7ef --- /dev/null +++ b/models/challenges/biffno.ts @@ -0,0 +1,68 @@ +import mongoose, {Schema, PopulatedDoc, Document, Model} from "mongoose"; +import { IUser } from "../../models/user"; +import SequenceFactory from "mongoose-sequence"; +import { hasMigrated } from "../../lib/dbconfig"; + +const AutoIncrement = SequenceFactory(mongoose); + + +export interface IBiffno { + _id: number; + title: string; + description: string; + excerpt: string; + bands: number[]; + tags: string[]; + wordcount: number; + genre: string; + cover: string; + year: number; + author: PopulatedDoc +} + +const biffnoschema = new mongoose.Schema({ + _id: { + type: Number + }, + title: { + type: String, + default: "" + }, + description: { + type: String, + default: "" + }, + excerpt: { + type: String, + default: "" + }, + bands: [{ + type: Number, + ref: "Band" + }], + tags: [{ + type: String + }], + wordcount: { + type: Number, + default: 0 + }, + genre: { + type: String + }, + cover: { + type: String, + default: "" + }, + year: { + type: Number, + default: 0 + }, + author: { + type: Number, + ref: "User" + } +}); + +hasMigrated && biffnoschema.plugin(AutoIncrement, {start_seq: 1, id: "bif_id"}); +export const Biffno: Model = /* mongoose.models.Biffno || */ mongoose.model('Biffno', biffnoschema, 'biffno'); diff --git a/models/challenges/ficmas.ts b/models/challenges/ficmas.ts new file mode 100644 index 0000000..61c93fa --- /dev/null +++ b/models/challenges/ficmas.ts @@ -0,0 +1,45 @@ +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[]; + relationship: string; + wisher: PopulatedDoc; + anniversary: boolean; +} + +export const FicmasSchema = new mongoose.Schema({ + _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 = /* mongoose.models.Ficmas || */ model("Ficmas", FicmasSchema, "ficmas_wishes") diff --git a/models/challenges/gen.ts b/models/challenges/gen.ts new file mode 100644 index 0000000..f77d725 --- /dev/null +++ b/models/challenges/gen.ts @@ -0,0 +1,49 @@ +import mongoose, {Schema, PopulatedDoc, Document, Model} from "mongoose"; +import SequenceFactory from "mongoose-sequence"; +import { hasMigrated } from "../../lib/dbconfig"; + +const AutoIncrement = SequenceFactory(mongoose); + +export interface IChallenge { + _id: number; + name: string; + description: string; + deadline: Date; + active: boolean; + color: string; + allowMultiple: boolean; +} + +const challengeSchema = new mongoose.Schema({ + _id: { + type: Number + }, + name: { + type: String, + required: true + }, + description: { + type: String, + required: true + }, + deadline: { + type: Date, + required: true + }, + active: { + type: Boolean, + default: true + }, + color: { + type: String, + required: true, + default: `#${Math.floor(Math.random()*16777215).toString(16)}` + }, + allowMultiple: { + type: Boolean, + default: true + } +}) + +hasMigrated && challengeSchema.plugin(AutoIncrement, {id: "challenges"}); +export const Challenge: Model = /* mongoose.models.Challenge || */ mongoose.model("Challenge", challengeSchema, "challenges")