lib

package
v0.0.0-...-460480a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2018 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CREATED_AT = "createdAt"
	CREATOR    = "creator"
	SEARCH     = "search"
	NB_USE     = "nbUse"
)

Filters and orders

View Source
const (
	SrcCreations string = "creations"
	SrcPackages  string = "packages"
	SrcPreview   string = "previews"
	SrcProfile   string = "profiles"
	SrcCreaThumb string = "crea_thumb"
)

AWS S3 storage locations

Variables

View Source
var DB *sqlx.DB

DB driver

Functions

func DecodeHash

func DecodeHash(hash string) (int64, error)

DecodeHash returns the decoded id

func Encrypt

func Encrypt(toEncrypt string, salt []byte) (string, error)

Encrypt encrypt the string

func GenImage

func GenImage(id uint64) *image.RGBA

GenImage generates an almost unique cool image

func GenKey

func GenKey() string

GenKey generates random key

func GetCloudRepo

func GetCloudRepo() string

GetCloudRepo returns the cloud repository name

func GetEmailHost

func GetEmailHost() string

GetEmailHost returns email host with port

func GetEmailPasswd

func GetEmailPasswd() string

GetEmailPasswd returns email password

func GetEncKey

func GetEncKey() string

GetEncKey returns a key for encryptions

func GetOrigins

func GetOrigins() []string

GetOrigins returns origins for cors

func GetPkgRepo

func GetPkgRepo() string

GetPkgRepo returns the package repository

func GetPkgURL

func GetPkgURL() string

GetPkgURL returns packages URL

func GetTokenKey

func GetTokenKey() string

GetTokenKey returns the token's salt key

func GetTokenLifetime

func GetTokenLifetime() int

GetTokenLifetime returns token lifetime

func HashID

func HashID(id int64) (string, error)

HashID hashes uint64 id and returns a unique string

func LoadDB

func LoadDB()

LoadDB initializes the DB

Types

type Filter

type Filter struct {
	ID    string
	Value string
}

Filter is a query filter

type ID

type ID struct {
	ValueEncoded string
	ValueDecoded uint64
}

ID is a custom type for hashed IDs

func InitID

func InitID(data interface{}) ID

InitID returns an ID

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

MarshalJSON marshals custom ID

func (*ID) Scan

func (id *ID) Scan(value interface{}) error

Scan implements the Scanner interface

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals custom NullString

func (ID) Value

func (id ID) Value() (driver.Value, error)

Value implements the driver Valuer interface

type NullInt64

type NullInt64 struct {
	sql.NullInt64
}

NullInt64 is psql null for string

func InitNullInt64

func InitNullInt64(val int64) *NullInt64

InitNullInt64 returns a NullInt64 with int64 "val"

func (NullInt64) MarshalJSON

func (ni NullInt64) MarshalJSON() ([]byte, error)

MarshalJSON marshals custom NullString

func (*NullInt64) UnmarshalJSON

func (ni *NullInt64) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals custom NullInt64

type NullString

type NullString struct {
	sql.NullString
}

NullString is psql null for string

func InitNullString

func InitNullString(str string) *NullString

InitNullString returns a NullString with String "str"

func (NullString) MarshalJSON

func (ns NullString) MarshalJSON() ([]byte, error)

MarshalJSON marshals custom NullString

type NullTime

type NullTime struct {
	pq.NullTime
}

NullTime is psql null for time.Time

func InitNullTime

func InitNullTime(date time.Time) *NullTime

InitNullTime returns a NullTime with Time "date"

func (NullTime) MarshalJSON

func (v NullTime) MarshalJSON() ([]byte, error)

MarshalJSON marshals custom NullTime

func (*NullTime) UnmarshalJSON

func (v *NullTime) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals custom NullTime

type Option

type Option struct {
	Filters   *[]Filter
	Limit     int64
	Offset    int64
	Sort      *Sort
	Populates []string
}

Option is query option

func ParseOptions

func ParseOptions(c *gin.Context) Option

ParseOptions parses query options

func (*Option) GetFilter

func (o *Option) GetFilter(queryFilter string) *Filter

GetFilter returns the filter object

func (*Option) GetSort

func (o *Option) GetSort(orderKey string) *Sort

GetSort returns the sort object It controls if the sort key exists in the filters, for security reasons so that it only consider known fields

func (*Option) HasPopulate

func (o *Option) HasPopulate(key string) bool

HasPopulate return true if it contains populate "key"

type Query

type Query struct {
	Q   string
	Opt *Option

	// Total of params contained in the query
	Values []interface{}
}

Query are query options

func NewQuery

func NewQuery(query string, opt *Option) *Query

NewQuery initiates a query

func (*Query) AddValues

func (q *Query) AddValues(values ...interface{})

AddValues add the values for the SQL query

func (*Query) SetBulkInsert

func (q *Query) SetBulkInsert(baseValues []interface{}, attrs []string, values ...interface{})

SetBulkInsert adds bulk insert to the query baseValues are values that doesn't change or bulk inserting (can be empty) atrs are attributes of the values interface values are the dynamic values to bulk insert (attrs relates to this interfaces slice)

func (*Query) SetFilters

func (q *Query) SetFilters(isAnding bool, filters ...string)

SetFilters adds sql filters (LIKE) to the query isAnding tells the parser if it has to start whith a WHERE clause (false) or AND close (true) filters are the string values to filter with LIKE %filtre%

func (*Query) SetOrder

func (q *Query) SetOrder(key string, field string)

SetOrder adds order to the query

func (*Query) String

func (q *Query) String() string

type SQLPatch

type SQLPatch struct {
	Fields []string
	Args   []interface{}
	Index  int
}

SQLPatch is a struct for parsed resource to be patched

func SQLPatches

func SQLPatches(resource interface{}) SQLPatch

SQLPatches parse the resource to be patched in the db (only update) source : https://play.golang.org/p/TdwAhb7pjT

func (*SQLPatch) GetUpdateQuery

func (sqlPatch *SQLPatch) GetUpdateQuery(table string) string

GetUpdateQuery build and return a db query string

type Sort

type Sort struct {
	Key   string
	Order string
}

Sort defines a ordering

type Storage

type Storage struct {
	Session *session.Session
	Source  string
	// contains filtered or unexported fields
}

Storage is Wooble cloud storage interface

func NewStorage

func NewStorage(src string) *Storage

NewStorage initialized a Storage session

func (*Storage) BulkDeleteFiles

func (s *Storage) BulkDeleteFiles()

BulkDeleteFiles delete pushed objects

func (*Storage) CopyAndStoreFile

func (s *Storage) CopyAndStoreFile(userID string, objID string, prevVersion string, version string, filename string)

CopyAndStoreFile copy and store cloud object

func (*Storage) DeleteFile

func (s *Storage) DeleteFile(userID string, objID string, version string, filename string)

DeleteFile delete a file from the cloud

func (*Storage) Error

func (s *Storage) Error() error

func (*Storage) GetFileContent

func (s *Storage) GetFileContent(userID string, objID string, version string, filename string) string

GetFileContent returns requested file from the cloud

func (*Storage) GetPathFor

func (s *Storage) GetPathFor(userID string, objID string, version string, filename string) string

GetPathFor returns object path

func (*Storage) PushBulkFile

func (s *Storage) PushBulkFile(userID string, objID string, version string, filename string)

PushBulkFile prepares multiple files to be processed in the cloud

func (*Storage) SetSource

func (s *Storage) SetSource(src string)

SetSource set storage source

func (*Storage) StoreFile

func (s *Storage) StoreFile(content interface{}, contentType string, userID string, objID string, version string, filename string) string

StoreFile stores the file in the cloud

type StringSlice

type StringSlice []string

StringSlice see https://gist.github.com/adharris/4163702

func (StringSlice) MarshalJSON

func (s StringSlice) MarshalJSON() ([]byte, error)

MarshalJSON marshals custom ID

func (*StringSlice) Scan

func (s *StringSlice) Scan(src interface{}) error

Scan scans StringSlice

func (*StringSlice) String

func (s *StringSlice) String() string

func (StringSlice) Value

func (s StringSlice) Value() (driver.Value, error)

Value returns StringSlice as psql value

type UintSlice

type UintSlice []uint64

UintSlice if a uint slice for sql driver

func (*UintSlice) Scan

func (us *UintSlice) Scan(src interface{}) error

Scan scans UintSlice

func (UintSlice) Value

func (us UintSlice) Value() (driver.Value, error)

Value returns UintSlice as psql value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL