Skip to content

Adds PostGIS support to Bun ORM using Orb Geometry

License

Notifications You must be signed in to change notification settings

tingold/bunpostgis

Repository files navigation

PostGIS support for Bun ORM

Build, Lint, Test Go Report Card

This module provides a simple wrapper that allows PostGIS geometry types to be used in Bun. It builds on the awesome ewkb support already in 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 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 to be present to configure the database connection -- intended mostly for CI.