Skip to content

tinywasm/orm

Repository files navigation

tinywasm/orm

Project Badges

Ultra-lightweight, strongly-typed ORM engineered for WebAssembly and backend environments.

Documentation

Quick Start

1. Define your Model

// modules/user/model.go
package user

type User struct {
    ID    string `db:"pk"           json:"id"`
    Name  string                    `json:"name"`
    Email string `db:"unique"       json:"email"   form:"email"`
    Bio   string `form:"textarea"   json:"bio,omitempty"`
}

2. Generate the Boilerplate

Run ormc from your project root.

go install github.com/tinywasm/orm/cmd/ormc@latest
ormc

This generates modules/user/model_orm.go with the Model implementation and typed helpers.

Tip

Automatic Sync: ormc automatically runs go get for required dependencies and go mod tidy if a go.mod is detected.

3. Use it

import (
    "github.com/tinywasm/orm"
    "yourproject/modules/user"
)

func GetActiveUsers(db *orm.DB) ([]*user.User, error) {
    return user.ReadAllUser(
        db.Query(&user.User{}).
            Where(user.User_.Email).Like("%@gmail.com").
            Limit(10),
    )
}

Features

  • Standard Library Only: No external assertion libraries or heavy dependencies.
  • Isomorphic & Agnostic: Works identically in Go (backend) and WASM (frontend). Generated code contains no build tags.
  • Interface over Reflection: Zero use of reflect at runtime for maximum performance.
  • Typed Schema: Uses github.com/tinywasm/fmt for deterministic field mapping.
  • Boilerplate Generator: ormc CLI tool automates the Model interface implementation and handles dependencies.

About

tiny orm data base adapter

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages