Created
April 25, 2022 02:34
-
-
Save alfiankan/70873922fe9f26848a156667f6eec146 to your computer and use it in GitHub Desktop.
Location repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DatabaseError, Pool, QueryResult } from "pg"; | |
import { Point } from "../entities/Point"; | |
class Locations { | |
private db: Pool | |
constructor(pool: Pool) { | |
this.db = pool | |
} | |
getPointsInsideBoundingBox(west: string, south: string, east: string, north: string): Promise<QueryResult<any>> { | |
return this.db.query({ | |
text: "SELECT id, ST_Y(location) AS y, ST_X(location) as x FROM marker_cluster u WHERE location && ST_MakeEnvelope($1, $2, $3, $4, 4326)", | |
values: [west, south, east, north] | |
}) | |
} | |
} | |
export { Locations } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment