github.com/pavlo67/common@v0.5.3/common/db/options.go (about) 1 package db 2 3 //type Identity struct { 4 // Identity *auth.Identity 5 // Selector *selectors.Term 6 // // Tx interface{} 7 //} 8 // 9 //func (options *Identity) GetIdentity() *auth.Identity { 10 // if options == nil { 11 // return nil 12 // } 13 // return options.Identity 14 //} 15 // 16 //func (options *Identity) GetSelector() *selectors.Term { 17 // if options == nil { 18 // return nil 19 // } 20 // return options.Selector 21 //} 22 // 23 //func (options *Identity) HasRole(oneOfRoles ...rbac.Role) bool { 24 // if options == nil || options.Identity == nil { 25 // return false 26 // } 27 // 28 // return options.Identity.Roles.Has(oneOfRoles...) 29 //} 30 31 //func (options *Identity) WithSelector(selector selectors.Term) *Identity { 32 // if options == nil { 33 // return &Identity{Selector: &selector} 34 // } 35 // optionsCopied := *options 36 // optionsCopied.Selector = &selector 37 // 38 // return &optionsCopied 39 //} 40 //func OptionsWithRoles(roles ...rbac.Role) *Identity { 41 // return &Identity{ 42 // Identity: &auth.Identity{ 43 // Roles: roles, 44 // }, 45 // } 46 //}