:man-shrugging: Hello fellow Prisma fans…. I’m str...
# orm-help
c
🤷‍♂️ Hello fellow Prisma fans…. I’m struggling to find any help or info with dealing with Geometry / Geographical Data / Coordinates, etc instructions with Prisma. To better explain, my client has an existing database that I’m migrating over to use Prisma. It’s a Postgres db with Postgis features activated, which adds coordinate data and allows for sql queries with coordinate points . When I run prisma introspect, it successfully reads the tables, but comments out the value
geometry
stating
# Type 'USER-DEFINED' is not yet supported.
. Here is the SQL query and expected returned value of the column.
Copy code
SELECT ST_AsGeoJSON(logs.geometry) FROM logs

{ type: "LineString", coordinates: [[-79.895893,40.445344],[-79.895914,40.44529]] }
if I don’t use
ST_AsGeoJSON
I get a value with only A-Z0-9 characters, such as
010200000002000000CE3637A627FD...
That said, when using Prisma, I’d like for Prisma to extract the data by wrapping the query using
ST_AsGeoJSON
so that it returns the object
geometry: {type: String, coordinates:[[Float]]}
... instead of
geometry: String
. I’m also trying to do this easily, with as little of ‘custom’ code as possible. Does anyone have a solution or workaround that would solve my dilemma? 1. Do I need to need to pull the String and then using JS convert it on the frontend to the object? 2. Or is there a way to get Prisma to pass the query wrapper (eg
ST_AsGeoJSON
) so that it returns the object automatically? 3. What do I need to use as
type Geometry { type: String, coordinates: [[Float]] }
to get this to work? Right now it’s screaming at me as it doesn’t like the
[[Float]]
and that Geometry doesn’t have any relationships in the database. Any help is greatly appreciated! Thank you