Skip to content
/ velum Public

micro ORM. One allocation more comparing with raw database/sql or pgx

License

Notifications You must be signed in to change notification settings

axkit/velum

Repository files navigation

velum

Build Status Go Report Card GoDoc Coverage Status

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)

About

micro ORM. One allocation more comparing with raw database/sql or pgx

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages