import mongoose from 'mongoose'; const userSchema = new mongoose.Schema({ googleId: { type: String, required: true, unique: true, }, email: { type: String, required: true, unique: true, }, displayName: String, firstName: String, lastName: String, username: { type: String, unique: true, sparse: true, // 👈 THIS IS THE FIX trim: true, minlength: 3, maxlength: 30, }, role: { type: String, default: 'user' }, // Profile Details (Filled during Onboarding) profile: { isComplete: { type: Boolean, default: false }, college: { type: String, default: '' }, city: { type: String, default: '' }, gender: { type: String, enum: ['Male', 'Female', 'Non-binary', ''], default: '' }, relationshipStatus: { type: String, default: '' }, photos: [String], // Array of Cloudinary URLs bio: { type: String, maxlength: 100 }, socials: { instagram: { type: String, default: '' }, snapchat: { type: String, default: '' }, whatsapp: { type: String, default: '' } // Optional per Bible } }, // The Cragy Safety Engine karma: { type: Number, default: 60, // Starts in "Normal" range (50-79) min: 0, max: 100 }, flags: { nsfwCount: { type: Number, default: 0 }, reportsReceived: { type: Number, default: 0 }, isBanned: { type: Boolean, default: false } }, // Social Layer friends: [{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }], friendRequests: [{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }] }, { timestamps: true }); export default mongoose.model('User', userSchema);