bur: An ORM framework implementation in Go.

Related tags

ORM bur
Overview

bur

An ORM framework implementation in Go(based on sg).

Go Report Card GoDoc

Quickstart

package main

import (
  "database/sql"
  "fmt"
  . "github.com/go-the-way/bur"
  "github.com/go-the-way/sg"
  _ "github.com/go-sql-driver/mysql"
)

const (
  testDriverName = "mysql"
  testDSN        = "root:[email protected](192.168.0.252:3310)/test"
)

var (
  testDB, _ = sql.Open(testDriverName, testDSN)
)

type userModel struct {
  ID         int    `orm:"pk{T} column{id} insertIgnore{T} definition{id int not null auto_increment comment 'ID'}"`
  Name       string `orm:"pk{F} column{name} definition{name varchar(50) not null default 'hello world' comment 'Name'}"`
  Age        int    `orm:"pk{F} column{age} definition{age int not null default '20' comment 'Age'}"`
  Address    string `orm:"pk{F} column{address} definition{address varchar(100) not null comment 'Address'}"`
  Phone      string `orm:"pk{F} column{phone} definition{phone varchar(11) not null default '13900000000' comment 'Phone'}"`
  CreateTime string `orm:"pk{F} column{create_time} insertIgnore{T} updateIgnore{T} definition{create_time datetime not null default current_timestamp comment 'CreateTime'}"`
  XYZ        string `orm:"pk{F} column{xyz} definition{xyz varchar(50) not null default 'xyz' comment 'XYZ'}"`
}

func (u *userModel) MetaData() *ModelMeta {
  return &ModelMeta{
    Migrate: true,
    Comment: "The userModel Table",
    IndexDefinitions: []sg.Ge{
      sg.IndexDefinition(false, sg.P("idx_name"), sg.C("name")),
    },
    InsertIgnores: []sg.C{"id", "create_time"},
  }   
}

func main() {
  DS(testDB)
  Register(new(userModel))
  o := New(new(userModel))
  count, err := o.Select().Count(&userModel{ID: 1})
  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println("count = ", count)
  }
}
Owner
go-the-way
Another go the way!
go-the-way
Using-orm-with-db - Trying to use ORM to work with PostgreSQL

Using ORM with db This repo contains the training (rough) code, and possibly not

Pavel V 5 Jul 31, 2022
SQL mapper ORM framework for Golang

SQL mapper ORM framework for Golang English 中文 Please read the documentation website carefully when using the tutorial. DOC Powerful Features High Per

null 0 Dec 8, 2021
Mybatis for golang - SQL mapper ORM framework

SQL mapper ORM framework for Golang English 中文 Please read the documentation website carefully when using the tutorial. DOC Powerful Features High Per

Tim 2 Jun 17, 2022
beedb is a go ORM,support database/sql interface,pq/mysql/sqlite

Beedb ❗ IMPORTANT: Beedb is being deprecated in favor of Beego.orm ❗ Beedb is an ORM for Go. It lets you map Go structs to tables in a database. It's

astaxie 708 Jul 24, 2022
A simple wrapper around sql.DB to help with structs. Not quite an ORM.

go-modeldb A simple wrapper around sql.DB to help with structs. Not quite an ORM. Philosophy: Don't make an ORM Example: // Setup require "modeldb" db

Jae Kwon 17 Nov 16, 2019
ORM-ish library for Go

We've moved! gorp is now officially maintained at: https://github.com/go-gorp/gorp This fork was created when the project was moved, and is provided f

James Cooper 53 Nov 22, 2021
Simple Go ORM for Google/Firebase Cloud Firestore

go-firestorm Go ORM (Object-relational mapping) for Google Cloud Firestore. Goals Easy to use Non intrusive Non exclusive Fast Features Basic CRUD ope

Jens Kjær Schødt 35 Jul 9, 2022
Database agnostic ORM for Go

If you are looking for something more lightweight and flexible, have a look at jet For questions, suggestions and general topics visit the group. Inde

Erik Aigner 696 Aug 8, 2022
QBS stands for Query By Struct. A Go ORM.

Qbs Qbs stands for Query By Struct. A Go ORM. 中文版 README ChangeLog 2013.03.14: index name has changed to {table name}_{column name}. For existing appl

Evan Zhou 551 Jun 23, 2022
Generate a Go ORM tailored to your database schema.

SQLBoiler is a tool to generate a Go ORM tailored to your database schema. It is a "database-first" ORM as opposed to "code-first" (like gorm/gorp). T

Volatile Technologies Inc. 5.1k Aug 15, 2022
Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle, Moved to https://gitea.com/xorm/xorm

xorm HAS BEEN MOVED TO https://gitea.com/xorm/xorm . THIS REPOSITORY WILL NOT BE UPDATED ANY MORE. 中文 Xorm is a simple and powerful ORM for Go. Featur

null 6.5k Aug 13, 2022
A better ORM for Go, based on non-empty interfaces and code generation.

reform A better ORM for Go and database/sql. It uses non-empty interfaces, code generation (go generate), and initialization-time reflection as oppose

null 1.3k Aug 3, 2022
100% type-safe ORM for Go (Golang) with code generation and MySQL, PostgreSQL, Sqlite3, SQL Server support. GORM under the hood.

go-queryset 100% type-safe ORM for Go (Golang) with code generation and MySQL, PostgreSQL, Sqlite3, SQL Server support. GORM under the hood. Contents

Denis Isaev 671 Aug 12, 2022
A better ORM for Go, based on non-empty interfaces and code generation.

A better ORM for Go and database/sql. It uses non-empty interfaces, code generation (go generate), and initialization-time reflection as opposed to interface{}, type system sidestepping, and runtime reflection. It will be kept simple.

null 1.3k Aug 3, 2022
Simple and performant ORM for sql.DB

Simple and performant ORM for sql.DB Main features are: Works with PostgreSQL, MySQL, SQLite. Selecting into a map, struct, slice of maps/structs/vars

Uptrace 1.3k Aug 15, 2022
An orm library support nGQL for Golang

norm An ORM library support nGQL for Golang. Overview Build insert nGQL by struct / map (Support vertex, edge). Parse Nebula execute result to struct

Zhihu 71 Aug 16, 2022
golang orm

korm golang orm, 一个简单易用的orm, 支持嵌套事务 安装 go get github.com/wdaglb/korm go get github.com/go-sql-driver/mysql 支持数据库 mysql https://github.com/go-sql-driv

null 6 Jul 18, 2022
Golang ORM with focus on PostgreSQL features and performance

go-pg is in a maintenance mode and only critical issues are addressed. New development happens in Bun repo which offers similar functionality but works with PostgreSQL, MySQL, and SQLite.

null 5.2k Aug 13, 2022
GorosePro(Go ORM),这个版本是Gorose的专业版

GorosePro(Go ORM),这个版本是Gorose的专业版

火线兔 2 Aug 10, 2022