https://github.com/tinywasm/postgres
PostgreSQL adapter for tinywasm/orm — pure Go, no CGO, supports WASM-compatible builds
https://github.com/tinywasm/postgres
database golang orm postgres-adapter postgresql tinywasm wasm
Last synced: 2 months ago
JSON representation
PostgreSQL adapter for tinywasm/orm — pure Go, no CGO, supports WASM-compatible builds
- Host: GitHub
- URL: https://github.com/tinywasm/postgres
- Owner: tinywasm
- Created: 2023-05-22T23:40:51.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2026-04-01T00:15:20.000Z (3 months ago)
- Last Synced: 2026-04-01T02:42:49.178Z (3 months ago)
- Topics: database, golang, orm, postgres-adapter, postgresql, tinywasm, wasm
- Language: Go
- Size: 164 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# PostgreSQL Adapter for tinywasm/orm

This repository implements the `orm.Adapter` interface for PostgreSQL, allowing it to be used with the `github.com/tinywasm/orm` library.
## Usage
```go
package main
import (
"log"
"github.com/tinywasm/postgres"
"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...
}
```
## Features
- Full `orm.Adapter` implementation.
- Transaction support via `BeginTx`.
- Secure SQL generation with parameterized queries using `$1`, `$2`, etc.
- Support for `Create`, `ReadOne`, `ReadAll`, `Update`, `Delete`.
- Efficient row scanning.
## Update
`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.
```go
// ✅ 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)
```
## Documentation
- [Postgres Setup & Troubleshooting](docs/POSTGRES_SETUP.md)