Documentation ¶
Index ¶
- func BadRequest(c *gin.Context, err error)
- func BindValidate(o interface{}) error
- func GetCID(c *gin.Context) (string, error)
- func GetServicePath(key string) string
- func GetUnixTime() string
- func NewCID() string
- func NewConnection(ctx context.Context, uri string) *mongo.Client
- func NewOID() string
- func NewSpreader(nConcurrent int) *spreader
- func NotOk(c *gin.Context, value interface{})
- func Ok(c *gin.Context, value interface{})
- func PairValues(i, o interface{}) error
- func PairValuesArray(in interface{}, out *[]interface{}) error
- func ParseKindAndBody(c *gin.Context, kind string, result interface{}) error
- func ParseKindAndBodyArray(c *gin.Context, kind string, result *[]interface{}) error
- func RandNumStr(n int) string
- func RandStr(n int) string
- func RandStrLow(n int) string
- func UnWrap(payload io.ReadCloser, resultValues interface{}) error
- func Unauthorized(c *gin.Context, err error)
- func UnixToDate(unix string) (time.Time, error)
- func UnixToDateString(unix string, result *string) error
- func UnixToDateStringDefault(unix, defaultVal string) string
- func UnixToFullDateStringDefault(unix, defaultVal string) string
- func UnixToTimeFormatDefault(unix, format, defaultVal string) string
- func UnixToTimeStringDefault(unix, defaultVal string) string
- func UseMongoTransaction(ctx context.Context, mongoClient *mongo.Client, ...) error
- func WErr(error ...string) error
- func WrapRequest(kind string, values interface{}) interface{}
- func WrapToArr(results interface{}) interface{}
- type BasicCRUDer
- type Error
- type Param
- type Request
- type Response
- type TCreatedDate
- type TDate
- type TModifiedDate
- type TWrappedDate
- type TWrappedModifiedDate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
func GetServicePath ¶
func GetUnixTime ¶
func GetUnixTime() string
func NewSpreader ¶
func NewSpreader(nConcurrent int) *spreader
func PairValuesArray ¶
func PairValuesArray(in interface{}, out *[]interface{}) error
PairValues function
func ParseKindAndBody ¶
func ParseKindAndBodyArray ¶
func RandNumStr ¶
func RandStrLow ¶
func UnWrap ¶
func UnWrap(payload io.ReadCloser, resultValues interface{}) error
func Unauthorized ¶
func UnixToDateString ¶
func UnixToDateStringDefault ¶
func UnixToTimeFormatDefault ¶
Using a custom formatter overriding time.Format()
func UnixToTimeStringDefault ¶
func UseMongoTransaction ¶
func UseMongoTransaction(ctx context.Context, mongoClient *mongo.Client, transactionCallback func(sc *mongo.SessionContext) error, tryCount int) error
Passing session inside transactionCallback by value will referring to another session address. Session must be passed by reference instead of passed by value
func WrapRequest ¶
func WrapRequest(kind string, values interface{}) interface{}
Types ¶
type BasicCRUDer ¶
type BasicCRUDer interface { // GET GetByID(ID string, result interface{}) error GetByIDs(IDs []string, result interface{}) error GetByIDsToMaps(IDs []string, result *[]map[string]interface{}) error // CREATE Create(Payload interface{}) error // UPDATE UpdateByID(ID string, query interface{}) error UpdateAndGetByID(ID string, query interface{}, result interface{}) error // DELETE DeleteByID(ID string) error }
func UseBasicCRUD ¶
func UseBasicCRUD(ctx context.Context, collection *mongo.Collection) BasicCRUDer
Using basic CRUD in mongodb
type Error ¶
type Error struct { Code string `json:"code" bson:"code" binding:"required"` Message interface{} `json:"refs,omitempty" bson:"refs,omitempty"` }
Error struct
type Request ¶
type Request struct { Kind string `json:"kind" bson:"kind" binding:"required"` Values interface{} `json:"values" bson:"values" binding:"required"` }
Request struct
type Response ¶
type Response struct { Success bool `json:"success" bson:"success" binding:"required"` Kind string `json:"kind,omitempty" bson:"kind,omitempty"` Values interface{} `json:"values,omitempty" bson:"values,omitempty"` Error interface{} `json:"error,omitempty" bson:"error,omitempty"` }
Response struct
func (*Response) ParseError ¶
type TCreatedDate ¶
type TDate ¶
type TDate struct { TCreatedDate `bson:",inline"` TModifiedDate `bson:",inline"` }
type TModifiedDate ¶
type TWrappedDate ¶
type TWrappedDate struct {
DateAttribute TDate `bson:"date_attributes" json:"date_attributes"`
}
func CreateDate ¶
func CreateDate(creator string) TWrappedDate
type TWrappedModifiedDate ¶
type TWrappedModifiedDate struct {
DateAttribute TModifiedDate `bson:"date_attributes" json:"date_attributes"`
}
func UpdateDate ¶
func UpdateDate(modifier string) TWrappedModifiedDate
Click to show internal directories.
Click to hide internal directories.