https://github.com/tingold/bunpostgis
Adds PostGIS support to Bun ORM using Orb Geometry
https://github.com/tingold/bunpostgis
bun geospatial gis orm
Last synced: 5 months ago
JSON representation
Adds PostGIS support to Bun ORM using Orb Geometry
- Host: GitHub
- URL: https://github.com/tingold/bunpostgis
- Owner: tingold
- License: mit
- Created: 2022-08-22T15:11:43.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-25T21:11:32.000Z (almost 4 years ago)
- Last Synced: 2024-06-21T00:41:18.098Z (almost 2 years ago)
- Topics: bun, geospatial, gis, orm
- Language: Go
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PostGIS support for Bun ORM
[](https://github.com/tingold/bunpostgis/actions/workflows/go.yml) [](https://goreportcard.com/report/github.com/tingold/bunpostgis/pkg)
This module provides a simple wrapper that allows [PostGIS](https://postgis.net/) geometry types to be used in [Bun](https://bun.uptrace.dev/).
It builds on the awesome `ewkb` support already in [Orb](https://github.com/paulmach/orb).
**Only pgx supported**
Supports Point/MultiPoint, Linestring/MultiLinestring, Polygon/MultiPolygon.
### Usage
Use it in a struct and tag the type appropriately if you want Bun to be able to create the table:
```
type SampleStruct struct {
bun.BaseModel `bun:"bunpostgis_test_table"`
GeoField bunpostgis.PostgisGeometry `bun:"type:Geometry"`
Name string
}
```
See [`test/postgis_test.go`](test/postgis_test.go) for a full example
## Testing
Tests have been refactored into their own package to avoid unessesary imports when using the library.
This test expects [Postgres environment variables](https://www.postgresql.org/docs/current/libpq-envars.html) to be present to configure the database connection -- intended mostly for CI.