This repository implements the orm.Adapter interface for PostgreSQL, allowing it to be used with the github.com/tinywasm/orm library.
package main
import (
"log"
"github.com/cdvelop/postgre"
"github.com/tinywasm/orm"
)
func main() {
dsn := "postgres://user:password@localhost:5432/dbname?sslmode=disable"
db, err := postgre.New(dsn)
if err != nil {
log.Fatal(err)
}
// Use db...
}- Full
orm.Adapterimplementation. - Transaction support via
BeginTx. - Secure SQL generation with parameterized queries using
$1,$2, etc. - Support for
Create,ReadOne,ReadAll,Update,Delete. - Efficient row scanning.
db.Update always requires at least one Condition. This is enforced at
compile time by tinywasm/orm. There is no "update by PK implicitly" magic.
// ✅ Correct
if err := db.Update(&user, orm.Eq(User_.ID, user.ID)); err != nil { ... }
// ❌ Compile error (caught by tinywasm/orm — will not reach the PostgreSQL layer)
db.Update(&user)