const { Schema, model } = require('mongoose');

const postSchema = new Schema(
    {
        user_id: {
            type: Schema.Types.ObjectId,
            ref: 'User',
            required: true
        },
        content: {
            type: String,
            required: true,
            trim: true,
            maxlength: [500, 'Post content cannot exceed 500 characters']
        },
        image: {
            type: String,
            default: null
        },
        timestamp: {
            type: Date,
            default: Date.now
        },
    });

module.exports = model('Post', postSchema, 'posts');