grogu

module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2024 License: Apache-2.0

README

go-grogu

grogu

Grogu is performance oriented ORM-Like library written in golang

Initialization

The library uses struct as db fields. This means you do not need to specify the db fields more than once.

repo := base_repo.NewBaseRepo[CreateUserDbModel, UpdateUserDbModel, UserResDto](ctx, db, "public", "users", "user_id", false, "", "")

Create Example

user := CreateUserReqDto{
	UserTitle: "Test User",
}
meta := user.ToDbModel("This user has admin role")

repo.Create(meta, func(id int64) {
	record = 1
}, func(rec int64) {
	// negative rec refers to db errors
	record = rec
})

Update Example

user := UpdateUserReqDto{
	UserTitle: "Test User",
}
meta := user.ToDbModel("This user has admin role")

repo.Update(userId, meta, func() {
	record = 1
}, func(rec int64) {
	// negative rec refers to db errors
	record = rec
})

GetOne Example

userId := 1

repo.GetOne(userId, func(user UserResDto) {
	record = 1
	resData = user
}, func(rec int64) {
	// negative rec refers to db errors
	record = rec
})

DeleteOne Example

userId := 1

repo.DeleteOne(userId, func() {
	record = 1
}, func(rec int64) {
	// negative rec refers to db errors
	record = rec
})

Note: This library is not production ready. This means, you should not use it in your scalable/heavy projects

Development Priorities

  • Multiple Db Support (Postgresql, MariaDB, MongoDB, ClickHouse)

May the Force be with You!

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL