From 3c896aa95d6c18692d5e8762559639eb222864a6 Mon Sep 17 00:00:00 2001 From: SKULL-GOD Date: Sat, 12 Apr 2025 22:12:25 -0400 Subject: [PATCH] Create User.ts --- src/lib/scripts/User.ts | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/lib/scripts/User.ts 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