Documentation
¶
Index ¶
- Constants
- func IdStrings(ids []interface{}) []string
- func NewDB() (*runner.DB, error)
- type ApiCollection
- type AuthToken
- type AuthTokenApi
- type AuthTokenDb
- func (db *AuthTokenDb) ById(id interface{}) (*AuthToken, error)
- func (db *AuthTokenDb) ByIds(ids []interface{}) ([]*AuthToken, error)
- func (db *AuthTokenDb) Delete(id interface{}) error
- func (db *AuthTokenDb) Hydrate(authTokens []*AuthToken) error
- func (db *AuthTokenDb) Save(authToken *AuthToken) error
- func (db *AuthTokenDb) Truncate() error
- type BackendModel
- type DownloadCounts
- type DownloadHourApi
- type DownloadHourDb
- func (db *DownloadHourDb) CountByFile(fileId string) (DownloadCounts, error)
- func (db *DownloadHourDb) CountByModel(modelId string) (DownloadCounts, error)
- func (db *DownloadHourDb) CountsByFiles(fileIds []string) (map[string]DownloadCounts, error)
- func (db *DownloadHourDb) CountsByModels(modelIds []string) (map[string]DownloadCounts, error)
- func (db *DownloadHourDb) MarkDownload(fileId, userId, ip string, t time.Time) error
- func (db *DownloadHourDb) Truncate() error
- type File
- type FileApi
- type FileDb
- func (db *FileDb) ById(id interface{}) (*File, error)
- func (db *FileDb) ByIds(ids []interface{}) ([]*File, error)
- func (db *FileDb) ByModelId(modelId string) ([]*File, error)
- func (db *FileDb) ByModelIdFilenameLatest(modelId, filename string) (*File, error)
- func (db *FileDb) ByModelIdFrameworkFilename(modelId, framework, filename string) ([]*File, error)
- func (db *FileDb) ByModelIdLatest(modelId string) ([]*File, error)
- func (db *FileDb) CommitPending(modelId, filename, fileId string) error
- func (db *FileDb) Delete(id interface{}) error
- func (db *FileDb) DeletePending(modelId, filename string) error
- func (db *FileDb) Hydrate(files []*File) error
- func (db *FileDb) Save(f *File) error
- func (db *FileDb) ToDelete(modelId, filename string, n int) ([]*File, error)
- func (db *FileDb) Truncate() error
- type FileDownloads
- type Model
- type ModelApi
- type ModelDb
- func (db *ModelDb) ByDownloads(visibility string, start, end time.Time, limit int, last string) ([]*Model, error)
- func (db *ModelDb) ById(id interface{}) (*Model, error)
- func (db *ModelDb) ByIds(ids []interface{}) ([]*Model, error)
- func (db *ModelDb) ByUserId(userId string) ([]*Model, error)
- func (db *ModelDb) ByUserIdSlug(userId, slug string) (*Model, error)
- func (db *ModelDb) ByVisibility(visibility string, limit int, last string) ([]*Model, error)
- func (db *ModelDb) Delete(id interface{}) error
- func (db *ModelDb) Hydrate(models []*Model) error
- func (db *ModelDb) Save(model *Model) error
- func (db *ModelDb) Truncate() error
- type ModelDownloads
- type Scannable
- type User
- type UserApi
- type UserDb
- func (db *UserDb) ByEmail(email string) (*User, error)
- func (db *UserDb) ById(id interface{}) (*User, error)
- func (db *UserDb) ByIds(ids []interface{}) ([]*User, error)
- func (db *UserDb) ByUsername(username string) (*User, error)
- func (db *UserDb) Delete(id interface{}) error
- func (db *UserDb) Hydrate(users []*User) error
- func (db *UserDb) Save(user *User) error
- func (db *UserDb) Truncate() error
Constants ¶
View Source
const AUTH_TOKEN_TABLE = "auth_token"
View Source
const BCRYPT_COST = 10
View Source
const DOWNLOAD_HOUR_TABLE = "download_hour"
View Source
const FILE_TABLE = "file"
View Source
const MODEL_TABLE = "model"
View Source
const USER_TABLE = "auth_user"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApiCollection ¶
type ApiCollection struct { User UserApi AuthToken AuthTokenApi Model ModelApi File FileApi DownloadHour DownloadHourApi }
func NewApiCollection ¶
func NewApiCollection(db *runner.DB) *ApiCollection
func (*ApiCollection) BackendModels ¶
func (api *ApiCollection) BackendModels() []BackendModel
func (*ApiCollection) Truncate ¶
func (api *ApiCollection) Truncate() error
type AuthToken ¶
type AuthToken struct { Id string `db:"id" json:"id"` UserId string `db:"user_id" json:"user_id"` CreatedTime time.Time `db:"created_time" json:"created_time"` }
func NewAuthToken ¶
type AuthTokenApi ¶
type AuthTokenDb ¶
type AuthTokenDb struct { DB *runner.DB Api *ApiCollection }
func NewAuthTokenDb ¶
func NewAuthTokenDb(db *runner.DB, api *ApiCollection) *AuthTokenDb
func (*AuthTokenDb) ById ¶
func (db *AuthTokenDb) ById(id interface{}) (*AuthToken, error)
func (*AuthTokenDb) ByIds ¶
func (db *AuthTokenDb) ByIds(ids []interface{}) ([]*AuthToken, error)
func (*AuthTokenDb) Delete ¶
func (db *AuthTokenDb) Delete(id interface{}) error
func (*AuthTokenDb) Hydrate ¶
func (db *AuthTokenDb) Hydrate(authTokens []*AuthToken) error
func (*AuthTokenDb) Save ¶
func (db *AuthTokenDb) Save(authToken *AuthToken) error
func (*AuthTokenDb) Truncate ¶
func (db *AuthTokenDb) Truncate() error
type BackendModel ¶
type BackendModel interface {
Truncate() error
}
type DownloadCounts ¶
type DownloadHourApi ¶
type DownloadHourApi interface { MarkDownload(fileId, userId, ip string, t time.Time) error CountByFile(fileId string) (DownloadCounts, error) CountsByFiles(fileIds []string) (map[string]DownloadCounts, error) CountByModel(modelId string) (DownloadCounts, error) CountsByModels(modelIds []string) (map[string]DownloadCounts, error) Truncate() error }
type DownloadHourDb ¶
type DownloadHourDb struct { DB *runner.DB Api *ApiCollection }
func NewDownloadHourDb ¶
func NewDownloadHourDb(db *runner.DB, api *ApiCollection) *DownloadHourDb
func (*DownloadHourDb) CountByFile ¶
func (db *DownloadHourDb) CountByFile(fileId string) (DownloadCounts, error)
func (*DownloadHourDb) CountByModel ¶
func (db *DownloadHourDb) CountByModel(modelId string) (DownloadCounts, error)
func (*DownloadHourDb) CountsByFiles ¶
func (db *DownloadHourDb) CountsByFiles(fileIds []string) (map[string]DownloadCounts, error)
func (*DownloadHourDb) CountsByModels ¶
func (db *DownloadHourDb) CountsByModels(modelIds []string) (map[string]DownloadCounts, error)
func (*DownloadHourDb) MarkDownload ¶
func (db *DownloadHourDb) MarkDownload(fileId, userId, ip string, t time.Time) error
func (*DownloadHourDb) Truncate ¶
func (db *DownloadHourDb) Truncate() error
type File ¶
type File struct { Id string `db:"id" json:"id"` UserId string `db:"user_id" json:"user_id"` ModelId string `db:"model_id" json:"model_id"` Filename string `db:"filename" json:"filename"` Status string `db:"status" json:"status"` Framework string `db:"framework" json:"framework"` FrameworkVersion string `db:"framework_version" json:"framework_version"` ClientName string `db:"client_name" json:"client_name"` SizeBytes int `db:"size_bytes" json:"size_bytes"` MetadataString string `db:"metadata" json:"-"` Metadata map[string]interface{} `db:"-" json:"metadata"` CreatedTime time.Time `db:"created_time" json:"created_time"` // Hydrated fields Downloads *DownloadCounts `db:"-" json:"downloads,omitempty"` }
func (*File) BlobFilename ¶
func (*File) FillMetadata ¶
type FileApi ¶
type FileApi interface { ById(id interface{}) (*File, error) ByIds(ids []interface{}) ([]*File, error) Delete(id interface{}) error Save(*File) error Hydrate([]*File) error Truncate() error // TODO: Potentially this should be a separate interface ByModelIdFilenameLatest(modelId, filename string) (*File, error) ByModelIdFrameworkFilename(modelId, framework, filename string) ([]*File, error) ByModelIdLatest(modelId string) ([]*File, error) ByModelId(modelId string) ([]*File, error) DeletePending(modelId, filename string) error CommitPending(modelId, filename, fileId string) error ToDelete(modelId, filename string, n int) ([]*File, error) }
type FileDb ¶
type FileDb struct { DB *runner.DB Api *ApiCollection }
func (*FileDb) ByModelIdFilenameLatest ¶
func (*FileDb) ByModelIdFrameworkFilename ¶
func (*FileDb) CommitPending ¶
func (*FileDb) DeletePending ¶
type FileDownloads ¶
type FileDownloads struct { FileId string `db:"file_id"` DownloadCounts }
type Model ¶
type Model struct { Id string `db:"id" json:"id"` UserId string `db:"user_id" json:"user_id"` Slug string `db:"slug" json:"slug"` Name string `db:"name" json:"name"` Description string `db:"description" json:"description"` Visibility string `db:"visibility" json:"visibility"` Keep int `db:"keep" json:"keep"` Readme string `db:"readme" json:"-"` CreatedTime time.Time `db:"created_time" json:"created_time"` // Hydrated fields Downloads *DownloadCounts `db:"-" json:"downloads,omitempty"` HydratedReadme zero.String `db:"-" json:"readme,omitempty"` }
type ModelApi ¶
type ModelApi interface { ById(id interface{}) (*Model, error) ByIds(ids []interface{}) ([]*Model, error) Delete(id interface{}) error Save(*Model) error Hydrate([]*Model) error Truncate() error // TODO: Potentially this should be a separate interface ByUserId(userId string) ([]*Model, error) ByUserIdSlug(userId, slug string) (*Model, error) ByVisibility(visibility string, limit int, last string) ([]*Model, error) ByDownloads(visibility string, start, end time.Time, limit int, last string) ([]*Model, error) }
type ModelDb ¶
type ModelDb struct { DB *runner.DB Api *ApiCollection }
func NewModelDb ¶
func NewModelDb(db *runner.DB, api *ApiCollection) *ModelDb
func (*ModelDb) ByDownloads ¶
func (*ModelDb) ByVisibility ¶
type ModelDownloads ¶
type ModelDownloads struct { ModelId string `db:"model_id"` DownloadCounts }
type User ¶
type User struct { Id string `db:"id" json:"id"` Email string `db:"email" json:"-"` Username string `db:"username" json:"username"` PasswordHash string `db:"password_hash" json:"-"` StripeCustomerId string `db:"stripe_customer_id" json:"-"` CreatedTime time.Time `db:"created_time" json:"created_time"` // Hydrated fields HasStripeCustomerId zero.Bool `json:"has_stripe_customer_id,omitempty"` }
func (*User) CheckPassword ¶
func (*User) SetPassword ¶
type UserApi ¶
type UserApi interface { ById(id interface{}) (*User, error) ByIds(ids []interface{}) ([]*User, error) Delete(id interface{}) error Save(*User) error Hydrate([]*User) error Truncate() error // TODO: Potentially this should be a separate interface ByEmail(email string) (*User, error) ByUsername(username string) (*User, error) }
type UserDb ¶
type UserDb struct { DB *runner.DB Api *ApiCollection }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.