transcreation-backend / models /WeeklyPracticeFile.js
Tristan Yu
feat(weekly-practice): add file uploads for week practice (admin source, student translation)
a29dc5e
const mongoose = require('mongoose');
const weeklyPracticeFileSchema = new mongoose.Schema({
type: {
type: String,
enum: ['source', 'translation'],
required: true
},
weekNumber: {
type: Number,
required: true,
index: true
},
// Optional link to a specific source file when type === 'translation'
sourceFileId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'WeeklyPracticeFile'
},
// Uploader info (required for translations, optional for source uploads)
userId: {
type: String
},
username: {
type: String
},
fileName: {
type: String,
required: true
},
mimeType: {
type: String,
required: true
},
size: {
type: Number,
required: true
},
// Store the file contents in MongoDB as a Buffer
data: {
type: Buffer,
required: true
},
description: {
type: String
}
}, { timestamps: true });
module.exports = mongoose.model('WeeklyPracticeFile', weeklyPracticeFileSchema);