Skip to content

tinywasm/postgres

Repository files navigation

PostgreSQL Adapter for tinywasm/orm

Project Badges

This repository implements the orm.Adapter interface for PostgreSQL, allowing it to be used with the github.com/tinywasm/orm library.

Usage

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...
}

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.

// ✅ 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages