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