const mongoose = require('mongoose');

const VCardSchema = new mongoose.Schema(
  {
    id: { type: String, unique: true, required: true }, // Unique, string identifier
    firstName: { type: String, required: false },
    lastName: { type: String, required: false },
    organization: { type: String, required: false },
    title: { type: String, required: false },
    workPhone: { type: String, required: false },
    workPhone2: { type: String, required: false },
    email: { type: String, required: false },
    url: { type: String, required: false },
    image_url: { type: String, required: false }, // URL for the image
    note: { type: String, required: false },
    address: { type: String, required: false },
    map: { type: String, required: false },
  },
  { timestamps: true } // Automatically add createdAt and updatedAt fields
);

// Ensure unique index on `id`
VCardSchema.index({ id: 1 }, { unique: true });

module.exports = mongoose.model('VCard', VCardSchema);
