import mongoose from 'mongoose'; const tempoSchema = new mongoose.Schema({ inizio: String, bpm: String, metro: String, battito: String, }, { _id: false }); const songSchema = new mongoose.Schema({ id: { type: String, required: true, unique: true }, title: { type: String, required: true }, artist: String, composer: String, album: String, grouping: String, genre: String, kind: String, size: String, totalTime: String, discNumber: String, trackNumber: String, year: String, averageBpm: String, dateAdded: String, bitRate: String, sampleRate: String, comments: String, playCount: String, rating: String, location: String, // Original file path from Rekordbox XML remixer: String, tonality: String, label: String, mix: String, tempo: tempoSchema, // S3 file integration (preserves original location) s3File: { musicFileId: { type: mongoose.Schema.Types.ObjectId, ref: 'MusicFile' }, s3Key: String, s3Url: String, streamingUrl: String, hasS3File: { type: Boolean, default: false } } }, { timestamps: true, versionKey: false, toJSON: { transform: function(doc, ret) { ret.id = ret.id || ret._id; delete ret._id; delete ret.__v; return ret; } } }); // Create indexes for performance songSchema.index({ 's3File.hasS3File': 1 }); songSchema.index({ location: 1 }); export const Song = mongoose.model('Song', songSchema);