Thank you in advance. I have scavenged the internet for a working example/documentation for a way to store location point (longitude, latitude), find distance between two points, find points within a given distance. I am using typeorm, nestjs, postgresql.
(I already tried Mariadb but St_distance_sphere is not working there so am going with postgresql)
this is my entity
@ApiProperty({
type: String,
title: 'current_location',
example: '{"type":"Point","coordinates":[28.612849, 77.229883]}',
})
@Index({ spatial: true })
@Column({
type: 'geometry',
srid: 4326,
nullable: true,
spatialFeatureType: 'Point',
transformer: {
to: (v: Point) => {
console.log(JSON.stringify(v));
return eval(`ST_GeomFromGeoJSON(${JSON.stringify(v)})`);
},
from: (v: any) => {
return { type: 'Point', coordinates: [v.x, v.y] } as Point;
},
},
})
current_location: string;
there seem to be too much postgres/postgis documentation but nothing useful for my case. any help is much appreciated. I have been stuck on this for more than a week.
*note: I don't want to use JSONB datatype for its slower speed.




