Forge

Installation

Add dbswitch and a backend to your Go module.

GitHub

Requires Go 1.26+.

Core package

The core dbswitch package has no third-party dependencies:

go get github.com/anukool23/dbswitch@latest

Backend

Each backend lives in its own sub-package, so you only pull in a driver you actually use.

PostgreSQL (brings in jackc/pgx):

go get github.com/anukool23/dbswitch/postgres

MongoDB (brings in the official Go driver):

go get github.com/anukool23/dbswitch/mongo

DynamoDB (brings in aws-sdk-go-v2):

go get github.com/anukool23/dbswitch/dynamodb

Import

import (
	"github.com/anukool23/dbswitch"
	"github.com/anukool23/dbswitch/postgres" // or .../mongo, .../dynamodb
)

Use the dbswitch package to describe schema (Table, Column, types, defaults), the shared Store interface, and shared errors; use a backend package (postgres, mongo, or dynamodb) to open a connection and run CRUD. Continue to the Quick start, then see Backends for the differences between them.

On this page