Categorygithub.com/a631807682/sqlcommenter-gorm
repositorypackage
0.1.0-beta.1
Repository: https://github.com/a631807682/sqlcommenter-gorm.git
Documentation: pkg.go.dev

# README

sqlcommenter-gorm

gorm plugin for https://github.com/google/sqlcommenter

go report card test status MIT license Go.Dev reference visitor badge

sqlcommenter is a suite of middlewares/plugins that enable your ORMs to augment SQL statements before execution, with comments containing information about the code that caused its execution. This helps in easily correlating slow performance with source code and giving insights into backend database performance. In short it provides some observability into the state of your client-side applications and their impact on the database’s server-side.

Usage

    ...
    db.Use(sqlcommentergorm.Default())
    ...
    sess := DB.Scopes(sqlcommentergorm.ContextInject(ctx)).Session(&gorm.Session{})
    sess.Create(&user)
    // inject the following comments
    /* action='mockHandler',db_driver='mysql',framework='gorm',route='GET--%2Fmytest%2F%3Aid' */