Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ajeetkumarrauniyar/d81ae6333b6ad7aa2d27df90720e7279 to your computer and use it in GitHub Desktop.

Select an option

Save ajeetkumarrauniyar/d81ae6333b6ad7aa2d27df90720e7279 to your computer and use it in GitHub Desktop.
Sample DataSet Schema for Social Media Analytics Module
// src/models/Post.ts
import mongoose from 'mongoose';
const PostSchema = new mongoose.Schema({
postId: {
type: String,
required: true,
unique: true,
},
postType: {
type: String,
required: true,
enum: ['text', 'image', 'video', 'link'],
},
content: {
type: String,
required: true,
},
engagement: {
likes: { type: Number, default: 0 },
shares: { type: Number, default: 0 },
comments: { type: Number, default: 0 },
},
metadata: {
platform: String,
audience: Object,
hashtags: [String],
},
createdAt: {
type: Date,
default: Date.now,
},
updatedAt: {
type: Date,
default: Date.now,
},
});
export default mongoose.models.Post || mongoose.model('Post', PostSchema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment