File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 7979END;
8080```
8181
82+ ### JSON Columns
83+
84+ Use either JSON type—both fully support ` INSERT ` , ` UPDATE ` , and ` DELETE ` … ` RETURNING ` :
85+
86+ - ` gorm.io/datatypes.JSON ` — convenient for logging/printing; returned as text then rewrapped.
87+ - ` encoding/json.RawMessage ` — raw ` []byte ` fast-path; ideal for large payloads or minimal decoding.
88+
89+ #### Notes:
90+ - On multi-row ` RETURNING ` , we use PL/SQL bulk blocks and map results back into your structs.
91+ - ` datatypes.JSON ` comes back as text; ` json.RawMessage ` comes back as bytes.
92+
93+ Take the following struct as an example:
94+
95+ ``` go
96+ type Record struct {
97+ ID uint ` gorm:"primaryKey;autoIncrement;column:record_id"`
98+ Name string ` gorm:"column:name"`
99+ // Text-oriented JSON
100+ Properties datatypes.JSON ` gorm:"column:properties"`
101+ // Raw bytes JSON
102+ Payload json.RawMessage ` gorm:"column:payload"`
103+ }
104+ ```
105+
82106## Contributing
83107
84108This project welcomes contributions from the community. Before submitting a pull request, please [ review our contribution guide] ( ./CONTRIBUTING.md )
You can’t perform that action at this time.
0 commit comments