Create Post.ts

This commit is contained in:
SKULL-GOD
2025-04-12 23:20:33 -04:00
parent b8259eca00
commit 5478e9586e

30
src/lib/scripts/Post.ts Normal file
View File

@@ -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<any>;
upsert: any;
constructor() {
this.model = mongoose.model('post', postSchema);
this.upsert = { upsert: true };
}
async create(imageDes: string, reactions: Array<any>) {
const newEntry = new this.model({
imageDes: imageDes,
timeStamp: new Date().toISOString(),
reactions: reactions,
});
await newEntry.save();
return newEntry;
}
}