feat: add ORM_DEBUG env option (#14709)

Signed-off-by: Moshe Immerman <moshe@flanksource.com>
This commit is contained in:
Moshe Immerman 2021-05-12 04:56:30 +02:00 committed by GitHub
parent bd9a1c6722
commit d1b553fd3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@ import (
"context"
"errors"
"fmt"
"os"
"strconv"
"strings"
@ -47,6 +48,12 @@ func RegisterModel(models ...interface{}) {
type ormKey struct{}
func init() {
if os.Getenv("ORM_DEBUG") == "true" {
orm.Debug = true
}
}
// FromContext returns orm from context
func FromContext(ctx context.Context) (orm.Ormer, error) {
o, ok := ctx.Value(ormKey{}).(orm.Ormer)