go-gorm / gorm

The fantastic ORM library for Golang, aims to be developer friendly
https://gorm.io
MIT License
37.09k stars 3.94k forks source link

How to solve computed a field? #5999

Open uugaa opened 1 year ago

uugaa commented 1 year ago

Your Question

how to solve computed a field?

My solve

type Exam struct { ID int Name string Point string }

db.raw("select id, name, ST_AsText(ST_centroid(geom)) as point").Scan(&result) this computed field ST_AsText(ST_centroid(geom)) as point

The document you expected this should be explained

Can you decide maybe

type Exam struct { ID int gorm:"primaryKey;column:id" Name string Geom string //postgis geometry field Point string gorm:"computed:ST_AsText(ST_centroid(geom))" maby Total int gorm:"computed:sum(amount)" etc }

github-actions[bot] commented 10 months ago

This issue has been automatically marked as stale because it has been open 360 days with no activity. Remove stale label or comment or this will be closed in 180 days