Documentation
¶
Index ¶
- Variables
- func GetAllKeywords(db *gorm.DB, pq httputil.PaginationQuery) ([]Keyword, Paginator, error)
- func GetAllModules(db *gorm.DB, pq httputil.PaginationQuery) ([]Module, Paginator, error)
- func GetAllNodes(db *gorm.DB, pq httputil.PaginationQuery) ([]Node, Paginator, error)
- func GetAllUsers(db *gorm.DB, pq httputil.PaginationQuery) ([]User, Paginator, error)
- func NewNullInt64(i int64) sql.NullInt64
- func NewNullString(s string) sql.NullString
- func SearchModules(db *gorm.DB, query string, pq httputil.PaginationQuery) ([]Module, Paginator, error)
- func SearchNodes(db *gorm.DB, query string, pq httputil.PaginationQuery) ([]Node, Paginator, error)
- type BugTracker
- type BugTrackerJSON
- type GormModelJSON
- type Keyword
- type KeywordJSON
- type Location
- type LocationJSON
- type Module
- func (m Module) AddOwner(db *gorm.DB, owner User) (Module, error)
- func (m *Module) BeforeSave(tx *gorm.DB) error
- func (m Module) GetLatestVersion(db *gorm.DB) (ModuleVersion, error)
- func (m Module) MarshalJSON() ([]byte, error)
- func (m Module) Star(db *gorm.DB, userID uint) (int64, error)
- func (m Module) UnStar(db *gorm.DB, userID uint) (int64, error)
- func (m Module) Upsert(db *gorm.DB) (Module, error)
- func (m Module) UserStarred(db *gorm.DB, userID uint) (bool, error)
- type ModuleAuthors
- type ModuleJSON
- type ModuleKeywords
- type ModuleOwnerInvite
- type ModuleVersion
- type ModuleVersionJSON
- type Node
- type NodeJSON
- type Paginator
- type User
- func (u *User) AfterFind(tx *gorm.DB) error
- func (u User) ConfirmEmail(db *gorm.DB, uec UserEmailConfirmation) (User, error)
- func (u User) CountTokens(db *gorm.DB) int64
- func (u User) CreateToken(db *gorm.DB, name string) (UserToken, error)
- func (u User) Equal(other User) bool
- func (u User) GetTokens(db *gorm.DB) ([]UserToken, error)
- func (u User) MarshalJSON() ([]byte, error)
- func (u User) NewUserJSON() UserJSON
- func (u User) Upsert(db *gorm.DB) (User, error)
- type UserEmailConfirmation
- type UserJSON
- type UserModuleFavorite
- type UserToken
- type UserTokenJSON
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPaginationQuery = errors.New("invalid pagination query")
ErrInvalidPaginationQuery defines a sentinel error when an invalid pagination query is provided.
Functions ¶
func GetAllKeywords ¶
GetAllKeywords returns a slice of Keyword objects paginated by an offset, order and limit. An error is returned upon database query failure.
func GetAllModules ¶
GetAllModules returns a slice of Module objects paginated by an offset, order and limit. An error is returned upon database query failure.
func GetAllNodes ¶ added in v0.0.3
GetAllNodes returns a slice of Node records paginated by an offset, order and limit. An error is returned upon database query failure.
func GetAllUsers ¶
GetAllUsers returns a slice of User objects paginated by an offset, order and limit. An error is returned upon database query failure.
func NewNullInt64 ¶
func NewNullString ¶
func NewNullString(s string) sql.NullString
func SearchModules ¶
func SearchModules(db *gorm.DB, query string, pq httputil.PaginationQuery) ([]Module, Paginator, error)
SearchModules performs a paginated query for a set of modules by name, team, description or keywords. If no matching modules exist, an empty slice is returned.
func SearchNodes ¶ added in v0.0.3
SearchNodes performs a paginated query for a set of Node records by moniker, network, version or location. If any empty query is provided, we return a paginated list of all Node records. Otherwise, if no matching Node records exist, an empty slice is returned.
Types ¶
type BugTracker ¶
type BugTracker struct { gorm.Model URL sql.NullString `json:"url"` Contact sql.NullString `json:"contact"` ModuleID uint `json:"module_id"` }
BugTracker defines the metadata information for reporting bug reports on a given Module type.
func (BugTracker) MarshalJSON ¶
func (bt BugTracker) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for the BugTracker model.
func (BugTracker) NewBugTrackerJSON ¶ added in v0.0.2
func (bt BugTracker) NewBugTrackerJSON() BugTrackerJSON
type BugTrackerJSON ¶
type BugTrackerJSON struct { GormModelJSON URL interface{} `json:"url"` Contact interface{} `json:"contact"` ModuleID uint `json:"module_id"` }
BugTrackerJSON defines the JSON-encodeable type for a BugTracker.
type GormModelJSON ¶
type GormModelJSON struct { ID uint `json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
GormModelJSON defines a wrapper around a gorm.Model object that is used for JSON marshaling.
type Keyword ¶
Keyword defines a module keyword, where a module can have one or more keywords.
func (Keyword) MarshalJSON ¶
MarshalJSON implements custom JSON marshaling for the Keyword model.
func (Keyword) NewKeywordJSON ¶ added in v0.0.2
func (k Keyword) NewKeywordJSON() KeywordJSON
type KeywordJSON ¶
type KeywordJSON struct { GormModelJSON Name string `json:"name"` }
KeywordJSON defines the JSON-encodeable type for a Keyword.
type Location ¶ added in v0.0.3
type Location struct { ID uint `gorm:"primarykey"` CreatedAt time.Time UpdatedAt time.Time Country string Region string City string Latitude string Longitude string }
Location defines the geographical location of a crawled Tendermint node.
func QueryLocation ¶ added in v0.0.3
QueryLocation performs a query for a Location record. The resulting record, if it exists, is returned. If the query fails or the record does not exist, an error is returned.
func (Location) MarshalJSON ¶ added in v0.0.3
MarshalJSON implements custom JSON marshaling for the Location model.
func (Location) NewLocationJSON ¶ added in v0.0.3
func (l Location) NewLocationJSON() LocationJSON
type LocationJSON ¶ added in v0.0.3
type LocationJSON struct { GormModelJSON Country string `json:"country"` Region string `json:"region"` City string `json:"city"` Latitude string `json:"latitude"` Longitude string `json:"longitude"` }
LocationJSON defines the JSON-encodeable type for a Location.
type Module ¶
type Module struct { gorm.Model Name string `gorm:"not null;default:null"` Team string `gorm:"not null;default:null"` Homepage string Description string Stars int64 BugTracker BugTracker `gorm:"foreignKey:module_id"` Keywords []Keyword `gorm:"many2many:module_keywords"` Authors []User `gorm:"many2many:module_authors"` Owners []User `gorm:"many2many:module_owners"` Versions []ModuleVersion `gorm:"foreignKey:module_id"` Version ModuleVersion `gorm:"-"` // current version in manifest }
Module defines a Cosmos SDK module.
func GetModuleByID ¶
GetModuleByID returns a module by ID. If the module doesn't exist or if the query fails, an error is returned.
func GetUserModules ¶
GetUserModules returns a set of Module's authored by a given User by name.
func QueryModule ¶
QueryModule performs a query for a Module record. The resulting record, if it exists, is returned. If the query fails or the record does not exist, an error is returned.
func (Module) AddOwner ¶
AddOwner adds a given User as an owner to a Module and deletes the corresponding ModuleOwnerInvite record. It returns an error upon failure.
func (*Module) BeforeSave ¶
BeforeSave implements a GORM hook for updating a Module record before it is created or updated.
func (Module) GetLatestVersion ¶
func (m Module) GetLatestVersion(db *gorm.DB) (ModuleVersion, error)
GetLatestVersion returns a module's latest version record, if the module exists.
func (Module) MarshalJSON ¶
MarshalJSON implements custom JSON marshaling for the Module model.
func (Module) Star ¶
Star favorites a module by ID for a given userID. It returns an error upon failure, otherwise it returns the total nubmer of favorites for the module.
func (Module) UnStar ¶
UnStar removes a favorite for a module by ID for a given userID. It returns an error upon failure, otherwise it returns the total nubmer of favorites for the module.
func (Module) Upsert ¶
Upsert will attempt to either create a new Module record or update an existing record. A Module record is considered unique by a (name, team) index. In the case of the record existing, all primary and one-to-one fields will be updated, where authors and keywords are replaced. If the provided Version does not exist, it will be appended to the existing set of version relations. An error is returned upon failure. Upon success, the created or updated record will be returned.
type ModuleAuthors ¶
ModuleAuthors defines the type relationship between a module and all the associated authors.
type ModuleJSON ¶
type ModuleJSON struct { GormModelJSON Name string `json:"name"` Team string `json:"team"` Description string `json:"description"` Homepage string `json:"homepage"` Stars int64 `json:"stars"` BugTracker BugTrackerJSON `json:"bug_tracker"` Keywords []KeywordJSON `json:"keywords"` Authors []UserJSON `json:"authors"` Owners []UserJSON `json:"owners"` Versions []ModuleVersionJSON `json:"versions"` }
ModuleJSON defines the JSON-encodeable type for a Module.
type ModuleKeywords ¶
ModuleKeywords defines the type relationship between a module and all the associated keywords.
type ModuleOwnerInvite ¶
type ModuleOwnerInvite struct { CreatedAt time.Time UpdatedAt time.Time ModuleID uint InvitedUserID uint InvitedByUserID uint Token uuid.UUID }
ModuleOwnerInvite defines the a module owner invitation relationship.
func QueryModuleOwnerInvite ¶
func QueryModuleOwnerInvite(db *gorm.DB, query map[string]interface{}) (ModuleOwnerInvite, error)
QueryModuleOwnerInvite performs a query for a ModuleOwnerInvite record. The resulting record, if it exists, is returned. If the query fails or the record does not exist, an error is returned.
func (*ModuleOwnerInvite) BeforeSave ¶
func (moi *ModuleOwnerInvite) BeforeSave(_ *gorm.DB) error
BeforeSave will create and set the ModuleOwnerInvite UUID.
func (ModuleOwnerInvite) Upsert ¶
func (moi ModuleOwnerInvite) Upsert(db *gorm.DB) (ModuleOwnerInvite, error)
Upsert creates or updates a ModuleOwnerInvite record. If no record exists, a new record with a UUID token is created. Otherwise, the existing ModuleOwnerInvite record's UUID token is updated/regenerated. It returns an error up database failure.
type ModuleVersion ¶
type ModuleVersion struct { gorm.Model Documentation string Repo string `gorm:"not null;default:null"` Version string SDKCompat sql.NullString ModuleID uint PublishedBy uint }
ModuleVersion defines a version associated with a unique module.
func (ModuleVersion) MarshalJSON ¶
func (mv ModuleVersion) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for the ModuleVersion model.
func (ModuleVersion) NewModuleVersionJSON ¶ added in v0.0.2
func (mv ModuleVersion) NewModuleVersionJSON() ModuleVersionJSON
type ModuleVersionJSON ¶
type ModuleVersionJSON struct { GormModelJSON Version string `json:"version"` Documentation string `json:"documentation"` Repo string `json:"repo"` SDKCompat interface{} `json:"sdk_compat"` ModuleID uint `json:"module_id"` PublishedBy uint `json:"published_by"` }
BugTrackerJSON defines the JSON-encodeable type for a ModuleVersion.
type Node ¶ added in v0.0.3
type Node struct { ID uint `gorm:"primarykey"` CreatedAt time.Time UpdatedAt time.Time LocationID uint Location Location Address string RPCPort string `gorm:"column:rpc_port"` P2PPort string `gorm:"column:p2p_port"` Moniker string NodeID string Network string Version string TxIndex string }
Node defines a crawled Tendermint node.
func GetStaleNodes ¶ added in v0.0.3
GetStaleNodes returns all nodes that are stale. A node is considered stale if the updated_at timestamp is less than the provided time. An error is returned upon database failure.
func QueryNode ¶ added in v0.0.3
QueryNode performs a query for a Node record. The resulting record, if it exists, is returned. If the query fails or the record does not exist, an error is returned.
func (Node) Delete ¶ added in v0.0.3
Delete attempts to delete a Node record by its address. An error is returned upon query or delete failure. An error is not returned if the record does not exist.
func (Node) MarshalJSON ¶ added in v0.0.3
MarshalJSON implements custom JSON marshaling for the Node model.
func (Node) NewNodeJSON ¶ added in v0.0.3
type NodeJSON ¶ added in v0.0.3
type NodeJSON struct { GormModelJSON Location LocationJSON `json:"location"` Address string `json:"address"` RPCPort string `json:"rpc_port"` P2PPort string `json:"p2p_port"` Moniker string `json:"moniker"` NodeID string `json:"node_id"` Network string `json:"network"` Version string `json:"version"` TxIndex string `json:"tx_index"` }
NodeJSON defines the JSON-encodeable type for a Node.
type Paginator ¶
Paginator defines pagination result cursor metadata to determine how to make subsequent pagination calls.
type User ¶
type User struct { gorm.Model Name string FullName string URL string GravatarID string AvatarURL string GithubUserID sql.NullInt64 GithubAccessToken sql.NullString Email sql.NullString EmailConfirmed bool // many-to-many relationships Modules []Module `gorm:"many2many:module_owners"` // one-to-many relationships Tokens []UserToken `gorm:"foreignKey:user_id"` Stars []uint `gorm:"-"` }
User defines an entity that contributes to a Module type.
func GetUserByID ¶
GetUserByID returns a User by ID. If the user doesn't exist or if the query fails, an error is returned.
func QueryUser ¶
QueryUser performs a query for a User record. The resulting record, if it exists, is returned. If the query fails or the record does not exist, an error is returned.
func (*User) AfterFind ¶
AfterFind implements a GORM hook for updating a User record after it has been queried for.
func (User) ConfirmEmail ¶
ConfirmEmail confirms a user email confirmation by updating the User record's EmailConfirmed column and removing the associated UserEmailConfirmation record. It returns an error upon database failure.
func (User) CountTokens ¶
CountTokens returns the total number of API tokens belonging to a User.
func (User) CreateToken ¶
CreateToken creates a new UserToken for a given User model. It returns an error upon failure.
func (User) GetTokens ¶
GetTokens returns all UserToken records for a given User record. It returns an error upon failure.
func (User) MarshalJSON ¶
MarshalJSON implements custom JSON marshaling for the User model.
func (User) NewUserJSON ¶ added in v0.0.2
type UserEmailConfirmation ¶
type UserEmailConfirmation struct { CreatedAt time.Time UpdatedAt time.Time Email string UserID uint Token uuid.UUID }
UserEmailConfirmation defines a relation for confirming user email addresses.
func QueryUserEmailConfirmation ¶
func QueryUserEmailConfirmation(db *gorm.DB, query map[string]interface{}) (UserEmailConfirmation, error)
QueryUserEmailConfirmation performs a query for a UserEmailConfirmation record. The resulting record, if it exists, is returned. If the query fails or the record does not exist, an error is returned.
func (*UserEmailConfirmation) BeforeSave ¶
func (uec *UserEmailConfirmation) BeforeSave(_ *gorm.DB) error
BeforeSave will create and set the UserEmailConfirmation UUID.
func (UserEmailConfirmation) Upsert ¶
func (uec UserEmailConfirmation) Upsert(db *gorm.DB) (UserEmailConfirmation, error)
Upsert creates or updates a UserEmailConfirmation record. If no record exists for a given unique user ID, a new record with a UUID token is created. Otherwise, the existing UserEmailConfirmation record's UUID token is updated/regenerated. It returns an error up database failure.
type UserJSON ¶
type UserJSON struct { GormModelJSON Name string `json:"name"` FullName string `json:"full_name"` URL string `json:"url"` AvatarURL string `json:"avatar_url"` GravatarID string `json:"gravatar_id"` Email interface{} `json:"email"` EmailConfirmed bool `json:"email_confirmed"` Stars []uint `json:"stars"` }
UserJSON defines the JSON-encodeable type for a User.
type UserModuleFavorite ¶
UserModuleFavorite defines the behavior of a user staring a module record.
type UserToken ¶
type UserToken struct { gorm.Model Name string UserID uint Count uint Token uuid.UUID Revoked bool }
UserToken defines a user created API token.
func QueryUserToken ¶
QueryUserToken performs a query for a UserToken record. The resulting record, if it exists, is returned. If the query fails or the record does not exist, an error is returned.
func (*UserToken) BeforeCreate ¶
BeforeCreate will create and set the UserToken UUID.
func (UserToken) IncrCount ¶
IncrCount increments a token's count. It returns an error upon failure.
func (UserToken) MarshalJSON ¶
MarshalJSON implements custom JSON marshaling for the UserToken model.
type UserTokenJSON ¶
type UserTokenJSON struct { GormModelJSON Name string `json:"name"` UserID uint `json:"user_id"` Count uint `json:"count"` Token uuid.UUID `json:"token"` Revoked bool `json:"revoked"` }
UserTokenJSON defines the JSON-encodeable type for a UserToken.