type Customer struct {
ID int `dbw:"pk,gen=serial"`
FirstName string
LastName string
BirthDate date.Date `dbw:"bd"`
SSN string `dbw:"ssn"`
Address struct {
Line1 string
Line2 *string
CityID int
Country int
Zip string
}
Origin string `dbw:"-"`
RowVersion int64 `dbw:"version"`
CreatedAt time.Time `dbw:"insert"`
UpdatedAt *time.Time `dbw:"update"`
DeletedAt *time.Time `dbw:"delete"`
DeletedBy *int `dbw:"delete"`
}
// once
dbSql, err = sql.Open("postgres", connectionString)
dbwSql = sqlw.NewDatabaseWrapper(dbSql) // database sql wrapper here, pgx supported too
tbl := velum.NewTable[Customer]()
// get table row by primary key value
c, err := tbl.GetByPK(ctx, dbwSql, 42)
nc := Customer{FirstName: "Robert", LastName : "Egorov"}
err := tbl.Insert(ctx, dbSql, &nc)
fmt.Println("new customer id: ", nc.ID)
-
Notifications
You must be signed in to change notification settings - Fork 0
micro ORM. One allocation more comparing with raw database/sql or pgx
License
axkit/velum
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
micro ORM. One allocation more comparing with raw database/sql or pgx
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published