gorm Documentation

The fantastic ORM library for Golang, aims to be developer friendly

39,981 stars Go Go 2 files Β· ~496 tokens #go#golang#gorm#orm#web
RAW Doc

Docker & Self-Hosted Deployment Verified OCI

Deploy gorm on any server, homelab, or cloud container platform.

1-Click Terminal Command
bash (docker run)
docker run -d --name gorm -p 9910:9910 --restart always mysql:latest
Configured Services & Ports
βš™οΈ mysql
image: mysql:latest
πŸ”Œ Ports: 127.0.0.1:9910:3306
βš™οΈ postgres
image: postgres:latest
πŸ”Œ Ports: 127.0.0.1:9920:5432
βš™οΈ mssql
image: ${MSSQL_IMAGE}:latest
πŸ”Œ Ports: 127.0.0.1:9930:1433
βš™οΈ tidb
image: pingcap/tidb:v6.5.0
πŸ”Œ Ports: 127.0.0.1:9940:4000
βš™οΈ gaussdb
image: opengauss/opengauss:7.0.0-RC1.B023
πŸ”Œ Ports: 127.0.0.1:9950:5432
docker-compose.yml
yaml (docker-compose.yml)
services:
  mysql:
    image: 'mysql:latest'
    ports:
      - "127.0.0.1:9910:3306"
    environment:
      - MYSQL_DATABASE=gorm
      - MYSQL_USER=gorm
      - MYSQL_PASSWORD=gorm
      - MYSQL_RANDOM_ROOT_PASSWORD="yes"
  postgres:
    image: 'postgres:latest'
    ports:
      - "127.0.0.1:9920:5432"
    environment:
      - TZ=Asia/Shanghai
      - POSTGRES_DB=gorm
      - POSTGRES_USER=gorm
      - POSTGRES_PASSWORD=gorm
  mssql:
    image: '${MSSQL_IMAGE}:latest'
    ports:
      - "127.0.0.1:9930:1433"
    environment:
      - TZ=Asia/Shanghai
      - ACCEPT_EULA=Y
      - MSSQL_SA_PASSWORD=LoremIpsum86
  tidb:
    image: 'pingcap/tidb:v6.5.0'
    ports:
      - "127.0.0.1:9940:4000"
    command: /tidb-server -store unistore -path "" -lease 0s > tidb.log 2>&1 &
  gaussdb:
    image: 'opengauss/opengauss:7.0.0-RC1.B023'
    hostname: opengauss-server
    ports:
      - "127.0.0.1:9950:5432"
    environment:
      - TZ=Asia/Shanghai
      - GS_PASSWORD=Gaussdb@123
      - GS_CLUSTER_NAME=opengauss_cluster
      - PGDATA=/var/lib/opengauss/data
    entrypoint: ""
    command: |-
      /bin/sh -c 'set -euo pipefail;
      /usr/local/bin/entrypoint.sh gaussdb &
      counter=1;
      while [ "$$counter" -le 20 ]; do
        if su - omm -c "gsql -U omm -d postgres -c \"SELECT 1;\""; then
          echo "Creating database gorm...";
          su - omm -c "gsql -U omm -d postgres -c \"CREATE DATABASE gorm DBCOMPATIBILITY '\'PG\'';\"";
          echo "Database initialized successfully";
          break;
        fi;
        echo "Waiting for database to be ready... ($$counter/12)";
        sleep 5;
        counter=$$(($$counter + 1));
      done;
      # timeout handling
      if [ $$counter -gt 20 ]; then
        echo "Error: Database failed to start within timeout";
        exit 1;
      fi;
      # keep the container running: wait for the database process in the foreground
      wait
      '

Technical Documentation: go-gorm/gorm

ℹ️ Provenance: Multi-Tier Ingestion Β· CodeWiki Reference

Overview (`README.md`)

GORM

The fantastic ORM library for Golang, aims to be developer friendly.




Overview

  • Full-Featured ORM
  • Associations (Has One, Has Many, Belongs To, Many To Many, Polymorphism, Single-table inheritance)
  • Hooks (Before/After Create/Save/Update/Delete/Find)
  • Eager loading with Preload, Joins
  • Transactions, Nested Transactions, Save Point, RollbackTo to Saved Point
  • Context, Prepared Statement Mode, DryRun Mode
  • Batch Insert, FindInBatches, Find To Map
  • SQL Builder, Upsert, Locking, Optimizer/Index/Comment Hints, NamedArg, Search/Update/Create with SQL Expr
  • Composite Primary Key
  • Auto Migrations
  • Logger
  • Extendable, flexible plugin API: Database Resolver (Multiple Databases, Read/Write Splitting) / Prometheus…
  • Every feature comes with tests
  • Developer Friendly

Getting Started

Contributing

You can help to deliver a better GORM, check out things you can do

Contributors

Thank you for contributing to the GORM framework!

License

Β© Jinzhu, 2013~time.Now

Released under the MIT License


Overview (`tests/README.md`)

Test Guide

bash
cd tests
# prepare test databases
docker-compose up

# run all tests
./tests_all.sh

--- METRICS ---