import { SchemaFactory } from "@nestjs/mongoose";
import { Schema, Prop } from "@nestjs/mongoose";


export type CityDocument = City & Document;

@Schema({ timestamps: true })
export class City {
  @Prop({ type: Object, required: true })
  name: Record<string, string>;

  @Prop({
    type: {
      type: String,
      enum: ["Point"],
      default: "Point",
    },
    coordinates: {
      type: [Number],
      required: true,
    },
  })
  location: {
    type: "Point";
    coordinates: [number, number];
  };

  @Prop({ default: 1 })
  status: number;
}

export const CitySchema = SchemaFactory.createForClass(City);
CitySchema.index({ location: "2dsphere" });
