https://github.com/bobiverse/hstore
Go package for postgresql hstore type
https://github.com/bobiverse/hstore
golang-package postgresql
Last synced: 6 months ago
JSON representation
Go package for postgresql hstore type
- Host: GitHub
- URL: https://github.com/bobiverse/hstore
- Owner: bobiverse
- Created: 2021-05-27T07:29:29.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-16T11:59:33.000Z (almost 2 years ago)
- Last Synced: 2024-09-16T13:35:49.258Z (almost 2 years ago)
- Topics: golang-package, postgresql
- Language: Go
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hstore
Go package for postgresql hstore type ( https://www.postgresql.org/docs/13/hstore.html )
###
```go
package main
import (
"github.com/bobiverse/hstore"
// ...
)
type MyTest struct {
Name string
Data hstore.Hstore
// ...
}
func main() {
// Do database things and get values from database with `hstore` type
var my MyTest
my := dummy.GetSqlData("SELECT * FROM dummy LIMIT 1")
// Retrieve different data from hstore field
myname := my.Data.Get("name") // string
myage := my.Data.GetInt("age") // int
mytemperature := my.Data.GetFloat("temp") // float64
mytime := my.Data.GetTime("birth_time") // try to parse to `time.Time`
// Set new values or overwrites
my.Data.Set("token", "rnPTD4*xjBG2KR9%jt$a9R2Hh") // new field
myData.SetIn("age", 21) // set new age value
// Save to database (your code)
}