All Projects → btfak → sqlext

btfak / sqlext

Licence: Apache-2.0 license
extend gorm and gocql

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to sqlext

BEW-2.5-Strongly-Typed-Languages
💪 Learn and implement the design patterns and best practices that make Go a top choice at high-velocity startups like Lyft, Heroku, Docker, Medium, and more!
Stars: ✭ 14 (-12.5%)
Mutual labels:  gorm
simple-wallet
This is a simple wallet REST api that is capable of acount deposits and withdrawals, checking for account balance and providing a ministatement. It follows domain driven design practices. The project uses the DDD architecture approach.
Stars: ✭ 32 (+100%)
Mutual labels:  gorm
go-webapp-sample
golang, echo, gorm
Stars: ✭ 194 (+1112.5%)
Mutual labels:  gorm
go-pangu
rest api web server based on go(High availability, high security, high performance)
Stars: ✭ 45 (+181.25%)
Mutual labels:  gorm
grom
A powerful command line tool for converting mysql table fields to golang model structure.
Stars: ✭ 44 (+175%)
Mutual labels:  gorm
go-graphql-api-boilerplate
A Boilerplate of GraphQL API built in Go + graphql-go + gorm
Stars: ✭ 75 (+368.75%)
Mutual labels:  gorm
Goweibo
Go Weibo App
Stars: ✭ 243 (+1418.75%)
Mutual labels:  gorm
pink-lady
a template project of gin app.
Stars: ✭ 44 (+175%)
Mutual labels:  gorm
gorm-paginator
gorm pagination extension
Stars: ✭ 154 (+862.5%)
Mutual labels:  gorm
mysql
GORM mysql driver
Stars: ✭ 126 (+687.5%)
Mutual labels:  gorm
gorm-mongodb
GORM for MongoDB
Stars: ✭ 58 (+262.5%)
Mutual labels:  gorm
go-orm-code-helper
🔥🔥🔥go-orm-code-helper is a goland plugin, it aims to make gorm code getting more simple
Stars: ✭ 22 (+37.5%)
Mutual labels:  gorm
go api boilerplate
🐶Go (Golang)🚀REST / GraphQL API + Postgres boilerplate
Stars: ✭ 127 (+693.75%)
Mutual labels:  gorm
opentracing-gorm
OpenTracing instrumentation for GORM.
Stars: ✭ 46 (+187.5%)
Mutual labels:  gorm
gorm-neo4j
GORM for Neo4j
Stars: ✭ 16 (+0%)
Mutual labels:  gorm
golang-example-app
Example application
Stars: ✭ 138 (+762.5%)
Mutual labels:  gorm
prometheus
Collect DB Status or user-defined metrics with Prometheus
Stars: ✭ 94 (+487.5%)
Mutual labels:  gorm
gothic
🦇 Gothic is a user registration and authentication SWT/JWT microservice. It supports REST, gRPC, and gRPC Web API, reCAPTCHA & a variety of DBs with Gorm.
Stars: ✭ 65 (+306.25%)
Mutual labels:  gorm
iris-gorm-demo
iris+gorm+mysql的restful api项目起手式
Stars: ✭ 92 (+475%)
Mutual labels:  gorm
ginadmin
基于Gin开发的后台管理系统,集成了、数据库操作、日志管理、权限分配管理、多模板页面、自动分页器、数据库迁移和填充、Docker集成部署等功能、静态资源打包
Stars: ✭ 149 (+831.25%)
Mutual labels:  gorm

sqlext

sqlext use to extend gorm and gocql

  • gorm not support batch insert,BatchInsert is a universal batch insert API.
  • gocql not support bind querying data to struct,MapToStruct fill struct fields with map value

example

  • BatchInsert
type GroupMember struct {
	ID        int64
	GroupID   int64
	Type      int8
	Extra     []byte
	JoinTime  time.Time
}

var mydb *gorm.DB
var members = []GroupMember{}
sqlext.BatchInsert(mydb.DB(),members)

//generated SQL: INSERT INTO group_member (id, group_id, type, extra, join_time) VALUES (?,?,?,?,?), (?,?,?,?,?) ...
  • MapToStruct
// MapToStruct
func GetUsersByIDs(userIDs []int64) (users []User, err error) {
	iter := Cassandra.Query("SELECT * FROM user WHERE id IN ?", userIDs).Iter()
	for {
		row := make(map[string]interface{})
		if !iter.MapScan(row) {
			break
		}
		user := User{}
		err = sqlext.MapToStruct(row, &user)
		if err != nil {
			return nil, err
		}
		users = append(users, user)
	}
	return users, nil
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].