https://github.com/karpeleslab/psql
https://github.com/karpeleslab/psql
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/karpeleslab/psql
- Owner: KarpelesLab
- License: mit
- Created: 2022-10-12T11:14:31.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-03-14T07:49:29.000Z (over 1 year ago)
- Last Synced: 2025-07-01T00:08:52.928Z (12 months ago)
- Language: Go
- Size: 198 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: change.go
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/github.com/KarpelesLab/psql)
# psql
Platform SQL code, including object load/save & query builder.
This works in some ways similar to `gorm` but with focus on supporting and using modern Go syntax & features.
## Object binding
After defining a structure, you can use it to load/save data from database.
```go
type Table1 struct {
Key uint64 `sql:",key=PRIMARY"`
Name string `sql:"Name,type=VARCHAR,size=64"`
}
// ...
obj, err := psql.Get[Table1](context.Background(), map[string]any{"Key": 42}) // this fetches entry with Key=42
```
## go 1.23
New go 1.23 iterators can be used
```go
res, err := psql.Iter[Table1](context.Background(), map[string]any{"Type": "A"}) // this fetches entries with Type=A
if err != nil {
return err
}
for v := range res {
// v is of type *Table1
}
```
## Query builder