import mongoose, { Document, Schema } from 'mongoose';

export interface ISearch extends Document {
  userId: string;
  url: string;
  geo: string[];
  currency?: string;
  results?: Record<string, unknown>;
  createdAt: Date;
}

const SearchSchema = new Schema<ISearch>(
  {
    userId: { type: String, required: true, index: true },
    url: { type: String, required: true },
    geo: { type: [String], default: [] },
    currency: { type: String },
    results: { type: Schema.Types.Mixed },
  },
  { timestamps: true }
);

export const SearchModel = mongoose.model<ISearch>('Search', SearchSchema);
