I’ve built a nestjs application and in one of the schemas I defined a location field as follows:
the location field
@Prop({ type: LocationSchema, required: isRequired, index: '2dsphere' })
public location?: Location;
the LocationShcema
@Schema()
export class Location {
@Prop({ type: String, required: true })
public type = 'Point';
@Prop({ type: [Number, Number], required: true })
public coordinates: [number, number];
}
export const LocationSchema = SchemaFactory.createForClass(Location);
In production when requesting creation of a document it gives me this error:
MongoServerError: location object expected, location array not in correct format
I have two questions
- why does this error show up?
- why does it occur only in production?