Documentation ¶
Index ¶
- Variables
- func MustCreateClient(opts ...ConnectionOption) *sql.DB
- func NewClient(opts ...ConnectionOption) (*sql.DB, error)
- func NewPgxClient(opts ...ConnectionOption) *pgxpool.Pool
- type CollectionTokenRepository
- func (c *CollectionTokenRepository) Create(pCtx context.Context, pColl persist.CollectionDB) (persist.DBID, error)
- func (c *CollectionTokenRepository) Delete(pCtx context.Context, pID persist.DBID, pUserID persist.DBID) error
- func (c *CollectionTokenRepository) Update(pCtx context.Context, pID persist.DBID, pUserID persist.DBID, ...) error
- func (c *CollectionTokenRepository) UpdateTokens(pCtx context.Context, pID persist.DBID, pUserID persist.DBID, ...) error
- type CommentRepository
- type CommunityRepository
- type ConnectionOption
- func WithAppName(appName string) ConnectionOption
- func WithDBName(dbname string) ConnectionOption
- func WithHost(host string) ConnectionOption
- func WithNoRetries() ConnectionOption
- func WithPassword(password string) ConnectionOption
- func WithPort(port int) ConnectionOption
- func WithRetries(r retry.Retry) ConnectionOption
- func WithUser(user string) ConnectionOption
- type ContractGalleryRepository
- type ContractRepository
- func (c *ContractRepository) BulkUpsert(pCtx context.Context, pContracts []persist.Contract) error
- func (c *ContractRepository) GetByAddress(pCtx context.Context, pAddress persist.EthereumAddress) (persist.Contract, error)
- func (c *ContractRepository) GetContractsOwnedByAddress(ctx context.Context, addr persist.EthereumAddress) ([]persist.Contract, error)
- func (c *ContractRepository) MostRecentBlock(pCtx context.Context) (persist.BlockNumber, error)
- func (c *ContractRepository) UpdateByAddress(ctx context.Context, addr persist.EthereumAddress, ...) error
- type EarlyAccessRepository
- type ErrRoleDoesNotExist
- type EventRepository
- func (r *EventRepository) Add(ctx context.Context, event db.Event) (*db.Event, error)
- func (r *EventRepository) AddAdmireEvent(ctx context.Context, event db.Event) (*db.Event, error)
- func (r *EventRepository) AddCollectionEvent(ctx context.Context, event db.Event) (*db.Event, error)
- func (r *EventRepository) AddCommentEvent(ctx context.Context, event db.Event) (*db.Event, error)
- func (r *EventRepository) AddCommunityEvent(ctx context.Context, event db.Event) (*db.Event, error)
- func (r *EventRepository) AddDataOnlyEvent(ctx context.Context, event db.Event) (*db.Event, error)
- func (r *EventRepository) AddGalleryEvent(ctx context.Context, event db.Event) (*db.Event, error)
- func (r *EventRepository) AddPostEvent(ctx context.Context, event db.Event) (*db.Event, error)
- func (r *EventRepository) AddTokenEvent(ctx context.Context, event db.Event) (*db.Event, error)
- func (r *EventRepository) AddUserEvent(ctx context.Context, event db.Event) (*db.Event, error)
- func (r *EventRepository) EventsInWindow(ctx context.Context, eventID persist.DBID, windowSeconds int, ...) ([]db.Event, error)
- func (r *EventRepository) EventsInWindowForGallery(ctx context.Context, eventID, galleryID persist.DBID, windowSeconds int, ...) ([]db.Event, error)
- func (r *EventRepository) Get(ctx context.Context, eventID persist.DBID) (db.Event, error)
- func (r *EventRepository) IsActorActionActive(ctx context.Context, event db.Event, actions persist.ActionList, ...) (bool, error)
- func (r *EventRepository) IsActorGalleryActive(ctx context.Context, event db.Event, windowSize time.Duration) (bool, error)
- func (r *EventRepository) IsActorSubjectActionActive(ctx context.Context, event db.Event, actions persist.ActionList, ...) (bool, error)
- func (r *EventRepository) IsActorSubjectActive(ctx context.Context, event db.Event, windowSize time.Duration) (bool, error)
- type FeedRepository
- func (r *FeedRepository) Add(ctx context.Context, event db.FeedEvent) (*db.FeedEvent, error)
- func (r *FeedRepository) LastPublishedCollectionFeedEvent(ctx context.Context, ownerID persist.DBID, collectionID persist.DBID, ...) (*db.FeedEvent, error)
- func (r *FeedRepository) LastPublishedTokenFeedEvent(ctx context.Context, ownerID, tokenID persist.DBID, before time.Time, ...) (*db.FeedEvent, error)
- func (r *FeedRepository) LastPublishedUserFeedEvent(ctx context.Context, ownerID persist.DBID, before time.Time, ...) (*db.FeedEvent, error)
- type GalleryRepository
- func (g *GalleryRepository) AddCollections(pCtx context.Context, pID persist.DBID, pUserID persist.DBID, ...) error
- func (g *GalleryRepository) Create(pCtx context.Context, pGallery db.GalleryRepoCreateParams) (db.Gallery, error)
- func (g *GalleryRepository) Delete(pCtx context.Context, pGallery db.GalleryRepoDeleteParams) error
- func (g *GalleryRepository) GetPreviewsURLsByUserID(pCtx context.Context, pUserID persist.DBID, limit int) ([]string, error)
- func (g *GalleryRepository) Update(pCtx context.Context, pID persist.DBID, pUserID persist.DBID, ...) error
- type MembershipRepository
- func (m *MembershipRepository) GetAll(pCtx context.Context) ([]persist.MembershipTier, error)
- func (m *MembershipRepository) GetByTokenID(pCtx context.Context, pTokenID persist.HexTokenID) (persist.MembershipTier, error)
- func (m *MembershipRepository) UpsertByTokenID(pCtx context.Context, pTokenID persist.HexTokenID, ...) error
- type Repositories
- type UserRepository
- func (u *UserRepository) AddFollower(pCtx context.Context, follower persist.DBID, followee persist.DBID) (refollowed bool, err error)
- func (u *UserRepository) AddWallet(pCtx context.Context, pUserID persist.DBID, pChainAddress persist.ChainAddress, ...) error
- func (u *UserRepository) Create(pCtx context.Context, pUser persist.CreateUserInput, queries *db.Queries) (persist.DBID, error)
- func (u *UserRepository) Delete(pCtx context.Context, pID persist.DBID) error
- func (u *UserRepository) FillWalletDataForUser(pCtx context.Context, user *persist.User) error
- func (u *UserRepository) GetByChainAddress(pCtx context.Context, pChainAddress persist.L1ChainAddress) (persist.User, error)
- func (u *UserRepository) GetByID(pCtx context.Context, pID persist.DBID) (persist.User, error)
- func (u *UserRepository) GetByIDs(pCtx context.Context, pIDs []persist.DBID) ([]persist.User, error)
- func (u *UserRepository) GetByUsername(pCtx context.Context, pUsername string) (persist.User, error)
- func (u *UserRepository) GetByVerifiedEmail(pCtx context.Context, pEmail persist.Email) (persist.User, error)
- func (u *UserRepository) GetByWalletID(pCtx context.Context, pWalletID persist.DBID) (persist.User, error)
- func (u *UserRepository) MergeUsers(pCtx context.Context, pInitialUser persist.DBID, pSecondUser persist.DBID) error
- func (u *UserRepository) RemoveFollower(pCtx context.Context, follower persist.DBID, followee persist.DBID) error
- func (u *UserRepository) RemoveWallet(pCtx context.Context, pUserID persist.DBID, pWalletID persist.DBID) (bool, error)
- func (u *UserRepository) UpdateByID(pCtx context.Context, pID persist.DBID, pUpdate interface{}) error
- type WalletRepository
- func (w *WalletRepository) GetByChainAddress(ctx context.Context, chainAddress persist.L1ChainAddress) (persist.Wallet, error)
- func (w *WalletRepository) GetByID(ctx context.Context, ID persist.DBID) (persist.Wallet, error)
- func (w *WalletRepository) GetByUserID(ctx context.Context, userID persist.DBID) ([]persist.Wallet, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultConnectRetry = retry.Retry{MinWait: 2, MaxWait: 4, MaxRetries: 3}
Functions ¶
func MustCreateClient ¶
func MustCreateClient(opts ...ConnectionOption) *sql.DB
MustCreateClient panics when it fails to create a new database connection. By default, it will try to connect 3 times before returning an error.
func NewClient ¶
func NewClient(opts ...ConnectionOption) (*sql.DB, error)
NewClient creates a new Postgres client. By default, it will try to connect 3 times before returning an error.
func NewPgxClient ¶
func NewPgxClient(opts ...ConnectionOption) *pgxpool.Pool
NewPgxClient creates a new Postgres client via pgx. By default, it will try to connect 3 times before returning an error.
Types ¶
type CollectionTokenRepository ¶
type CollectionTokenRepository struct {
// contains filtered or unexported fields
}
CollectionTokenRepository is the repository for interacting with collections in a postgres database
func NewCollectionTokenRepository ¶
func NewCollectionTokenRepository(db *sql.DB, queries *db.Queries) *CollectionTokenRepository
NewCollectionTokenRepository creates a new CollectionTokenRepository TODO another join for addresses
func (*CollectionTokenRepository) Create ¶
func (c *CollectionTokenRepository) Create(pCtx context.Context, pColl persist.CollectionDB) (persist.DBID, error)
Create creates a new collection in the database
func (*CollectionTokenRepository) Delete ¶
func (c *CollectionTokenRepository) Delete(pCtx context.Context, pID persist.DBID, pUserID persist.DBID) error
Delete deletes a collection from the database
func (*CollectionTokenRepository) Update ¶
func (c *CollectionTokenRepository) Update(pCtx context.Context, pID persist.DBID, pUserID persist.DBID, pUpdate interface{}) error
Update updates a collection in the database
func (*CollectionTokenRepository) UpdateTokens ¶
func (c *CollectionTokenRepository) UpdateTokens(pCtx context.Context, pID persist.DBID, pUserID persist.DBID, pUpdate persist.CollectionUpdateTokensInput) error
UpdateTokens updates the nfts of a collection in the database
type CommentRepository ¶
type CommentRepository struct {
// contains filtered or unexported fields
}
CommentRepository represents an comment repository in the postgres database
func NewCommentRepository ¶
func NewCommentRepository(queries *db.Queries, pgx *pgxpool.Pool) *CommentRepository
NewCommentRepository creates a new postgres repository for interacting with comments
type CommunityRepository ¶
type CommunityRepository struct {
// contains filtered or unexported fields
}
CommunityRepository represents a community repository in the postgres database
func NewCommunityRepository ¶
func NewCommunityRepository(queries *db.Queries) *CommunityRepository
NewCommunityRepository creates a new postgres repository for interacting with communities
func (*CommunityRepository) UpsertCommunities ¶
func (c *CommunityRepository) UpsertCommunities(ctx context.Context, communities []db.Community) ([]db.Community, error)
UpsertCommunities upserts a list of communities
type ConnectionOption ¶
type ConnectionOption func(params *connectionParams)
func WithAppName ¶
func WithAppName(appName string) ConnectionOption
func WithDBName ¶
func WithDBName(dbname string) ConnectionOption
func WithHost ¶
func WithHost(host string) ConnectionOption
func WithNoRetries ¶
func WithNoRetries() ConnectionOption
func WithPassword ¶
func WithPassword(password string) ConnectionOption
func WithPort ¶
func WithPort(port int) ConnectionOption
func WithRetries ¶
func WithRetries(r retry.Retry) ConnectionOption
func WithUser ¶
func WithUser(user string) ConnectionOption
type ContractGalleryRepository ¶
type ContractGalleryRepository struct {
// contains filtered or unexported fields
}
ContractGalleryRepository represents a contract repository in the postgres database
func NewContractGalleryRepository ¶
func NewContractGalleryRepository(db *sql.DB, queries *db.Queries) *ContractGalleryRepository
NewContractGalleryRepository creates a new postgres repository for interacting with contracts
type ContractRepository ¶
type ContractRepository struct {
// contains filtered or unexported fields
}
ContractRepository represents a contract repository in the postgres database
func NewContractRepository ¶
func NewContractRepository(db *sql.DB) *ContractRepository
NewContractRepository creates a new postgres repository for interacting with contracts
func (*ContractRepository) BulkUpsert ¶
BulkUpsert bulk upserts the contracts by address
func (*ContractRepository) GetByAddress ¶
func (c *ContractRepository) GetByAddress(pCtx context.Context, pAddress persist.EthereumAddress) (persist.Contract, error)
GetByAddress returns the contract with the given address
func (*ContractRepository) GetContractsOwnedByAddress ¶
func (c *ContractRepository) GetContractsOwnedByAddress(ctx context.Context, addr persist.EthereumAddress) ([]persist.Contract, error)
GetContractsOwnedByAddress returns all contracts owned by the given address
func (*ContractRepository) MostRecentBlock ¶
func (c *ContractRepository) MostRecentBlock(pCtx context.Context) (persist.BlockNumber, error)
MostRecentBlock returns the most recent block number of any token
func (*ContractRepository) UpdateByAddress ¶
func (c *ContractRepository) UpdateByAddress(ctx context.Context, addr persist.EthereumAddress, up persist.ContractUpdateInput) error
UpdateByAddress updates the given contract's metadata fields by its address field.
type EarlyAccessRepository ¶
type EarlyAccessRepository struct {
// contains filtered or unexported fields
}
func NewEarlyAccessRepository ¶
func NewEarlyAccessRepository(db *sql.DB, queries *db.Queries) *EarlyAccessRepository
func (*EarlyAccessRepository) IsAllowedByAddresses ¶
func (u *EarlyAccessRepository) IsAllowedByAddresses(ctx context.Context, chainAddresses []persist.ChainAddress) (bool, error)
type ErrRoleDoesNotExist ¶
type ErrRoleDoesNotExist struct {
// contains filtered or unexported fields
}
func (ErrRoleDoesNotExist) Error ¶
func (e ErrRoleDoesNotExist) Error() string
type EventRepository ¶
func (*EventRepository) AddAdmireEvent ¶
func (*EventRepository) AddCollectionEvent ¶
func (*EventRepository) AddCommentEvent ¶
func (*EventRepository) AddCommunityEvent ¶
func (*EventRepository) AddDataOnlyEvent ¶
func (*EventRepository) AddGalleryEvent ¶
func (*EventRepository) AddPostEvent ¶
func (*EventRepository) AddTokenEvent ¶
func (*EventRepository) AddUserEvent ¶
func (*EventRepository) EventsInWindow ¶
func (r *EventRepository) EventsInWindow(ctx context.Context, eventID persist.DBID, windowSeconds int, actions persist.ActionList, includeSubject bool) ([]db.Event, error)
EventsInWindow returns events belonging to the same window of activity as the given eventID.
func (*EventRepository) EventsInWindowForGallery ¶
func (r *EventRepository) EventsInWindowForGallery(ctx context.Context, eventID, galleryID persist.DBID, windowSeconds int, actions persist.ActionList, includeSubject bool) ([]db.Event, error)
EventsInWindow returns events belonging to the same window of activity as the given eventID.
func (*EventRepository) IsActorActionActive ¶
func (*EventRepository) IsActorGalleryActive ¶
func (*EventRepository) IsActorSubjectActionActive ¶
type FeedRepository ¶
func (*FeedRepository) LastPublishedCollectionFeedEvent ¶
func (r *FeedRepository) LastPublishedCollectionFeedEvent(ctx context.Context, ownerID persist.DBID, collectionID persist.DBID, before time.Time, actions []persist.Action) (*db.FeedEvent, error)
LastPublishedCollectionFeedEvent returns the most recent collection event for the given owner, action, and collection that occurred before time `since`.
func (*FeedRepository) LastPublishedTokenFeedEvent ¶
type GalleryRepository ¶
type GalleryRepository struct {
// contains filtered or unexported fields
}
GalleryRepository is the repository for interacting with galleries in a postgres database
func NewGalleryRepository ¶
func NewGalleryRepository(queries *db.Queries) *GalleryRepository
NewGalleryRepository creates a new GalleryTokenRepository TODO another join to addresses
func (*GalleryRepository) AddCollections ¶
func (g *GalleryRepository) AddCollections(pCtx context.Context, pID persist.DBID, pUserID persist.DBID, pCollections []persist.DBID) error
AddCollections adds the given collections to the gallery with the given ID
func (*GalleryRepository) Create ¶
func (g *GalleryRepository) Create(pCtx context.Context, pGallery db.GalleryRepoCreateParams) (db.Gallery, error)
Create creates a new gallery
func (*GalleryRepository) Delete ¶
func (g *GalleryRepository) Delete(pCtx context.Context, pGallery db.GalleryRepoDeleteParams) error
Delete deletes a gallery and ensures that the collections of that gallery are passed on to another gallery
func (*GalleryRepository) GetPreviewsURLsByUserID ¶
type MembershipRepository ¶
type MembershipRepository struct {
// contains filtered or unexported fields
}
MembershipRepository is a repository for storing membership information in the database
func NewMembershipRepository ¶
func NewMembershipRepository(db *sql.DB, queries *db.Queries) *MembershipRepository
NewMembershipRepository creates a new postgres repository for interacting with tiers
func (*MembershipRepository) GetAll ¶
func (m *MembershipRepository) GetAll(pCtx context.Context) ([]persist.MembershipTier, error)
GetAll returns all the tiers
func (*MembershipRepository) GetByTokenID ¶
func (m *MembershipRepository) GetByTokenID(pCtx context.Context, pTokenID persist.HexTokenID) (persist.MembershipTier, error)
GetByTokenID returns the tier with the given token ID
func (*MembershipRepository) UpsertByTokenID ¶
func (m *MembershipRepository) UpsertByTokenID(pCtx context.Context, pTokenID persist.HexTokenID, pTier persist.MembershipTier) error
UpsertByTokenID upserts the given tier
type Repositories ¶
type Repositories struct { UserRepository *UserRepository GalleryRepository *GalleryRepository CollectionRepository *CollectionTokenRepository ContractRepository *ContractGalleryRepository MembershipRepository *MembershipRepository EarlyAccessRepository *EarlyAccessRepository WalletRepository *WalletRepository CommentRepository *CommentRepository EventRepository *EventRepository CommunityRepository *CommunityRepository // contains filtered or unexported fields }
Repositories is the set of all available persistence repositories
func NewRepositories ¶
func NewRepositories(pq *sql.DB, pgx *pgxpool.Pool) *Repositories
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
UserRepository represents a user repository in the postgres database
func NewUserRepository ¶
NewUserRepository creates a new postgres repository for interacting with users TODO joins for users to wallets and wallets to addresses
func (*UserRepository) AddFollower ¶
func (*UserRepository) AddWallet ¶
func (u *UserRepository) AddWallet(pCtx context.Context, pUserID persist.DBID, pChainAddress persist.ChainAddress, pWalletType persist.WalletType, queries *db.Queries) error
AddWallet adds an address to user as well as ensures that the wallet and address exists
func (*UserRepository) Create ¶
func (u *UserRepository) Create(pCtx context.Context, pUser persist.CreateUserInput, queries *db.Queries) (persist.DBID, error)
Create creates a new user
func (*UserRepository) FillWalletDataForUser ¶
func (*UserRepository) GetByChainAddress ¶
func (u *UserRepository) GetByChainAddress(pCtx context.Context, pChainAddress persist.L1ChainAddress) (persist.User, error)
GetByChainAddress gets the user who owns the wallet with the specified ChainAddress (if any)
func (*UserRepository) GetByIDs ¶
func (u *UserRepository) GetByIDs(pCtx context.Context, pIDs []persist.DBID) ([]persist.User, error)
GetByIDs gets all the users with the given IDs
func (*UserRepository) GetByUsername ¶
func (u *UserRepository) GetByUsername(pCtx context.Context, pUsername string) (persist.User, error)
GetByUsername gets the user with the given username
func (*UserRepository) GetByVerifiedEmail ¶
func (u *UserRepository) GetByVerifiedEmail(pCtx context.Context, pEmail persist.Email) (persist.User, error)
GetByEmail gets the user with the given email address
func (*UserRepository) GetByWalletID ¶
func (u *UserRepository) GetByWalletID(pCtx context.Context, pWalletID persist.DBID) (persist.User, error)
GetByWalletID gets the user with the given wallet in their list of addresses
func (*UserRepository) MergeUsers ¶
func (u *UserRepository) MergeUsers(pCtx context.Context, pInitialUser persist.DBID, pSecondUser persist.DBID) error
MergeUsers merges the given users into the first user
func (*UserRepository) RemoveFollower ¶
func (*UserRepository) RemoveWallet ¶
func (u *UserRepository) RemoveWallet(pCtx context.Context, pUserID persist.DBID, pWalletID persist.DBID) (bool, error)
RemoveWallet removes the specified wallet from a user. Returns true if the wallet exists and was successfully removed, false if the wallet does not exist or an error was encountered.
func (*UserRepository) UpdateByID ¶
func (u *UserRepository) UpdateByID(pCtx context.Context, pID persist.DBID, pUpdate interface{}) error
UpdateByID updates the user with the given ID
type WalletRepository ¶
type WalletRepository struct {
// contains filtered or unexported fields
}
WalletRepository is a repository for wallets
func NewWalletRepository ¶
func NewWalletRepository(db *sql.DB, queries *db.Queries) *WalletRepository
NewWalletRepository creates a new postgres repository for interacting with wallets
func (*WalletRepository) GetByChainAddress ¶
func (w *WalletRepository) GetByChainAddress(ctx context.Context, chainAddress persist.L1ChainAddress) (persist.Wallet, error)
GetByChainAddress returns a wallet by address and chain
func (*WalletRepository) GetByUserID ¶
func (w *WalletRepository) GetByUserID(ctx context.Context, userID persist.DBID) ([]persist.Wallet, error)
GetByUserID returns all wallets owned by the specified user