whatisgithub

What is gorm-d1-adapter?

intmian/gorm-d1-adapter — explained in plain English

Analysis updated 2026-05-18

39GoAudience · developerComplexity · 3/5Setup · moderate

In one sentence

A Go adapter that connects GORM or database/sql to Cloudflare D1, running 2 to 18 times faster through an included Worker proxy.

Mindmap

mindmap
  root((repo))
    What it does
      Connects Go to D1
      Worker proxy mode
      REST fallback mode
    Tech stack
      Go
      GORM
      Cloudflare Workers
      Cloudflare D1
    Use cases
      Use D1 from a Go backend
      Batch database operations
      Migrate off the old adapter
    Audience
      Go developers
      Cloudflare D1 users
    Performance
      18x faster connection
      6x faster batches
      Benchmarked results included

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Connect an existing Go and GORM application to Cloudflare D1 without rewriting it for Workers.

USE CASE 2

Deploy the included Worker proxy so services never handle a raw Cloudflare account token directly.

USE CASE 3

Batch multiple database reads and writes into a single fast, atomic request.

USE CASE 4

Migrate from the older, slower community D1 adapter using a compatible interface.

What is it built with?

GoGORMCloudflare D1Cloudflare Workers

How does it compare?

intmian/gorm-d1-adapterglockinhand/guns.lol-view-botvolcengine/mediakit-cli
Stars394040
LanguageGoGoGo
Setup difficultymoderatemoderatemoderate
Complexity3/53/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Worker mode requires deploying the included Cloudflare Worker proxy, REST mode needs a Cloudflare account API token and database ID.

No license information is stated in this description.

So what is it?

gorm-d1-adapter lets Go applications connect to Cloudflare's D1 database using the popular GORM library or Go's standard database/sql interface. Cloudflare does not provide an official Go library for D1, and an earlier community adapter broke when D1's API changed and was no longer maintained. The author rewrote the connector from scratch to fix that and make it much faster. The recommended way to connect is through a small Cloudflare Worker that the project includes. Instead of putting a Cloudflare account token directly into every Go service, that token stays inside the Worker, and Go services only need a simple access token to talk to it. This also lets multiple database operations get bundled into one request while keeping D1's built in guarantee that a batch either fully succeeds or fully rolls back. An older REST based connection mode, which talks to Cloudflare's API directly, is still available for existing setups or as a fallback. According to the project's own benchmarks, run on the same region and database for both modes, the Worker based connection opens about 18 times faster than the REST mode, and batches of database operations run about 6 times faster. Even single database operations are noticeably faster through the Worker. Using it means installing the Go package, choosing either Worker or REST mode in a small configuration object, and passing that into GORM as normal. Switching between the two modes later does not require changing application code. There are some limitations to be aware of: no interactive transactions, specific rules for how column names are interpreted as booleans or timestamps, and only basic table and column creation supported through GORM migrations, not more destructive changes like dropping columns.

Copy-paste prompts

Prompt 1
Help me set up gorm-d1-adapter in Worker mode with GORM for my Cloudflare D1 database.
Prompt 2
Explain the difference between Worker mode and REST mode in this D1 adapter and which one I should use.
Prompt 3
Walk me through deploying the included D1 Worker Proxy to Cloudflare.
Prompt 4
What are the current limitations of this adapter's GORM migrations that I should know before using it in production?

Frequently asked questions

What is gorm-d1-adapter?

A Go adapter that connects GORM or database/sql to Cloudflare D1, running 2 to 18 times faster through an included Worker proxy.

What language is gorm-d1-adapter written in?

Mainly Go. The stack also includes Go, GORM, Cloudflare D1.

What license does gorm-d1-adapter use?

No license information is stated in this description.

How hard is gorm-d1-adapter to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is gorm-d1-adapter for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.