wcamarao / pmx Goto Github PK
View Code? Open in Web Editor NEWGolang data mapping library for postgres and pgx
License: MIT License
Golang data mapping library for postgres and pgx
License: MIT License
I like the (very) lean premise of pmx
, since it enables us to avoid bloated ORMs.
However, the fact that for e.g. an pmx.Update
query there is no return value that enables us to see whether there was in fact an update (i.e. "RowsAffected") is problematic, since usually one would like to make this distinction (additionally to error/no-error).
So it would be better to have either (always/optionally?) commandTag
returned, or have an additional Update
wrapper that can be chosen to get more feedback.
type B struct {
Type string `db:"type" table:"games_bets"`
Game Game `db:"" table:"games"`
User storusermodel.User `db:"" table:"users"`
Amount float64 `db:"amount"`
Value string `db:"value"`
}
I have this struct, how i can scan into Game and User?
https://www.postgresql.org/docs/current/sql-insert.html#SQL-ON-CONFLICT
Instead of relying on duplicate key errors I'd like to use ON CONFLICT DO NOTHING and CommandTag.RowsAffected().
Also, as Update() seems to be removed (I'm currently on v0.0.0-20230325043427-5b6ceb086444) DO UPDATE would probably be also useful.
If I'm calling Insert and passing a struct is it possible to get it to return with the autogenerated fields filled in?
type Request struct {
ID uuid.UUID `json:"-" generated:"auto" db:"id" table:"sign_request_user"`
Request string `json:"request" db:"request"`
Created time.Time `json:"-" generated:"auto" db:"-"`
Updated time.Time `json:"-" generated:"auto" db:"-"`
Status string `json:"-" generated:"auto" db:"-"`
So I insert just the Request value into the struct and would get back filled in ID, Status and such.
Hi, I've stumbled over your library while searching for how to use the pgx struct tags with insert / update operations. In my opinion the pgx functionality is quite incomplete because it only allows for scanning. Don't you think it would be a better idea to try to upstream the functionality of your library to the pgx project?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.