惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
C
Check Point Blog
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Introducing Go DB ORM (v1.0.1) — A Type-Safe, Fluent ORM ...
Md Anik Isla · 2026-05-16 · via DEV Community

I’ve been working on an ORM for Go which is lightweight, easy to use, type-safe, and developer-friendly at its core.

The main goal of GoDB ORM is simple:

Make database handling in Go feel clean, predictable, and enjoyable — without heavy abstraction or hidden magic.

It is designed to feel like native Go, not a framework that hides what’s happening under the hood.

It also balances:

  1. Performance
  2. Simplicirt
  3. Flexibility

This is the first version of this package. So, it might not have all the features you expect from an ORM, and there could be some bugs in it.

But please give it a try. Your contributions, bug reports, feature requests, and feedback will be much appreciated.

Key Features:
1. Type-Safe Query Builder (Generic API)
No interface{} chaos — everything is strongly typed:

users, err := client.Query[User]().
    Where("city = ?", "Dhaka").
    Where("age > ?", 18).
    OrderBy("created_at DESC").
    Limit(10).
    Offset(20).
    All()

Enter fullscreen mode Exit fullscreen mode

  1. Compile-time safety
  2. No type casting
  3. Predictable results

2. Fluent & Clean API
Readable query chaining like natural language:

client.Model(&User{}).
    Where("active = ?", true).
    OrderBy("created_at DESC").
    Find()

Enter fullscreen mode Exit fullscreen mode

  1. Simple learning curve
  2. Familiar to GORM users
  3. Clean production code style

3. Schema-Driven Development (CLI Powered)
Define your database schema like this:

model User {
    id         int      @id
    name       string
    email      string
    city       string?
    created_at datetime
}

Enter fullscreen mode Exit fullscreen mode

Then generate everything automatically:

godborm migrate
godborm generate

  1. Auto migrations
  2. Auto Go struct generation
  3. Faster development workflow

4. Smart Relations with Include()

Load related data easily:

client.Query[Invoice]().
    Include("User:name,email").
    Include("Items:item_name,quantity").
    All()

Enter fullscreen mode Exit fullscreen mode

  1. Prevents unnecessary data loading
  2. Reduces DB cost
  3. Supports field-level selection

5. Smart CRUD Operations

user := &User{Name: "Alice", Email: "alice@example.com"}
client.Model(user).Save()   // Insert

user.Name = "Bob"
client.Model(user).Save()   // Update

client.Model(user).Delete() // Delete

Enter fullscreen mode Exit fullscreen mode

  1. Automatic insert/update detection
  2. Less boilerplate

6. Transactions Made Simple

err := client.WithTx(func(tx *client.Tx) error {
    tx.Create(&order)
    tx.Update(&inventory)
    return nil
})

Enter fullscreen mode Exit fullscreen mode

  1. Safe rollback handling
  2. Clean transactional flow

7. Raw SQL Support (Escape Hatch)

client.Raw("SELECT * FROM users WHERE email LIKE $1", "%@gmail.com").
    Scan(&users)

Enter fullscreen mode Exit fullscreen mode

  1. Full control when needed
  2. No restrictions

Lets Start Go DB ORM

Getting started takes only a few steps:

1. Install CLI

go install github.com/Anik2069/go-db-orm/cmd/godborm@latest

Enter fullscreen mode Exit fullscreen mode

2. Initialize ORM

godborm init

Enter fullscreen mode Exit fullscreen mode

This generates:
godborm.json
/schema folder

3. Define Your Schema

model User {
    id         int      @id
    name       string
    email      string
    city       string?
    created_at datetime
}

model Post {
    id       int      @id
    title    string
    user_id  int      @foreign(User.id)
}

Enter fullscreen mode Exit fullscreen mode

4. Run Migrations

godborm migrate

Enter fullscreen mode Exit fullscreen mode

5. Generate Models

godborm generate --package main

Enter fullscreen mode Exit fullscreen mode

6. Connect in Code

import "github.com/Anik2069/go-db-orm/godborm/client"

func main() {
    err := client.ConnectWithConfig()
    if err != nil {
        panic(err)
    }
    defer client.Close()
}

Enter fullscreen mode Exit fullscreen mode

🛠 Config
{
    "schema": "./schema",
    "migrations": "./migrations",
    "driver": "postgres",
    "dsn": "postgresql://user:pass@localhost:5432/dbname?sslmode=disable"
}

Enter fullscreen mode Exit fullscreen mode

Conclusion
This project is still evolving and actively improving. Contributions, feedback, bug reports, and feature ideas are highly welcome. If you’re interested in improving GoDB ORM, feel free to explore and contribute:

GitHub: https://github.com/Anik2069/go-db-orm

Let’s build something useful for the Go ecosystem together