diff --git a/src/lib/scripts/User.ts b/src/lib/scripts/User.ts new file mode 100644 index 0000000..4d20cf9 --- /dev/null +++ b/src/lib/scripts/User.ts @@ -0,0 +1,49 @@ +import mongoose from "mongoose"; + +const reqString = { + type: String, + required: true, +} + +const reqNumber = { + type: Number, + required: true, +} + +const reqBoolean = { + type: Boolean, + required: true, +} + +const userSchema = new mongoose.Schema({ + email: reqString, + username: reqString, + points: reqNumber, + owned: reqBoolean, + inventory : Array, + imageDescription: reqString, + ButtonsOptions: Array +});12 + +export class User { + model: mongoose.Model; + upsert: any; + constructor() { + this.model = mongoose.model('user', userSchema); + this.upsert = { upsert: true }; + } + async create(id: string, pickupLine: string, followUpLine: string, ButtonsOptions: Array, colors: any, image: any, password: string) { + const newEntry = new this.model({ + id: id, + pickupLine: pickupLine, + followUpLine: followUpLine, + ButtonsOptions: ButtonsOptions, + colors: colors, + image: image, + date: new Date().toISOString(), + password: password, + }); + await newEntry.save(); + return newEntry; + } +} \ No newline at end of file