Inserting and selecting PostGIS Geometry with Gorm

后端 未结 4 1803
星月不相逢
星月不相逢 2021-02-07 15:56

I\'ve been trying to find a way to insert and retrieve geometric types using Golang, and specifically the library gorm. I\'m also attempting to use the library orb that defines

4条回答
  •  广开言路
    2021-02-07 16:34

    Is it possible to make some sort of trigger or rule that would automatically call the needed functions on the data coming in/out?

    Ever tried gorm hooks, example:

    type Example struct {
        ID   int
        Name string
        Geom ...
    }
    
    func (e *Example) AfterFind() (err error) {
        e.Geom = ... // Do whatever you like here
        return
    }
    

    There is a handful of hooks that you can use. I find them pretty neat and useful.

提交回复
热议问题