From 5478e9586e755431be372543353836a9bee9e321 Mon Sep 17 00:00:00 2001 From: SKULL-GOD Date: Sat, 12 Apr 2025 23:20:33 -0400 Subject: [PATCH] Create Post.ts --- src/lib/scripts/Post.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/lib/scripts/Post.ts diff --git a/src/lib/scripts/Post.ts b/src/lib/scripts/Post.ts new file mode 100644 index 0000000..17f2d37 --- /dev/null +++ b/src/lib/scripts/Post.ts @@ -0,0 +1,30 @@ +import mongoose from "mongoose"; + +const reqString = { + type: String, + required: true, +}; + +const postSchema = new mongoose.Schema({ + imageDes: reqString, + timeStamp: Date, + reactions: Array, +}); + +export class Pickup { + model: mongoose.Model; + upsert: any; + constructor() { + this.model = mongoose.model('post', postSchema); + this.upsert = { upsert: true }; + } + async create(imageDes: string, reactions: Array) { + const newEntry = new this.model({ + imageDes: imageDes, + timeStamp: new Date().toISOString(), + reactions: reactions, + }); + await newEntry.save(); + return newEntry; + } +} \ No newline at end of file