Skip to content Skip to sidebar Skip to footer

How To Define Location In An Entity Using Mongodb

I am using nest js in my sample application. I define the entity of my application .Entity means a document. But I struck at one place to define the location. using mongoose I defi

Solution 1:

I think location would have similar structure to code below.

source 1source 2

enum GeoJSONPoint {
  Point = "Point"
}

enum Careers {
  WebDevelopment = 'Web Development',
  MobileDevelopment = 'Mobile Development',
  UIUX = 'UI/UX',
  DataScience = 'Data Science',
  Business = 'Business',
  Other = 'Other'
}

@Entity('location')
exportclassLocationEntityextendsBaseEntity {

  @Column({
    type: "enum",
    enum: GeoJSONPoint
  })
  type: GeoJSONPoint;

  @Column({type:'int'})
  coordinates: number;

  @Column({type:'text'})
  formattedAddress: string;

  @Column({type:'text'})
  street: string;

  @Column({type:'text'})
  city: string;

  @Column({type:'text'})
  state: string;

  @Column({type:'text'})
  zipcode: string;

  @Column({type:'text'})
  country: string;

  @Column({type:'simple-array'})
  careers: Careers[];
}

Post a Comment for "How To Define Location In An Entity Using Mongodb"