From 7e58dae6e7ba56d63e8b0cc583be012be85dea0e Mon Sep 17 00:00:00 2001 From: Craig Date: Sun, 28 Oct 2018 13:08:50 +0200 Subject: [PATCH] DB.Arg and DB.SetArg --- main.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/main.go b/main.go index 17c75ed3..263699bb 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,26 @@ type DB struct { callbacks *Callback dialect Dialect singularTable bool + + // Arguments you can add to a db + arg interface{} +} + +// SetArg allows you to set an application defined argument to +// a DB object. +func (db *DB) SetArg(i interface{}) { + db.arg = i +} +// Arg returns the application defined argument for the DB +// object. +func (db *DB) Arg() interface{} { + if nil!=db.arg { + return db.arg + } + if nil!=db.parent && db.parent!=db { + return db.parent.Arg() + } + return nil } // Open initialize a new db connection, need to import driver first, e.g: @@ -750,6 +770,7 @@ func (s *DB) GetErrors() []error { func (s *DB) clone() *DB { db := &DB{ + arg: s.arg, db: s.db, parent: s.parent, logger: s.logger,