Documentation
¶
Index ¶
- Constants
- func LayerInstance() *layer
- type Item
- type ItemPrice
- type ItemPriceQuery
- type ItemPriceTable
- type ItemQuery
- type ItemTable
- func (table *ItemTable) DeleteByID(id uuid.UUID) (err error)
- func (table *ItemTable) GetAll() (items []Item, err error)
- func (table *ItemTable) GetAllWithPrice() (items []ItemWithPrice, err error)
- func (table *ItemTable) GetByID(id uuid.UUID) (item Item, err error)
- func (table *ItemTable) GetWithPrice(id uuid.UUID) (item ItemWithPrice, err error)
- func (table *ItemTable) Insert(item Item) (returnedItem Item, err error)
- func (table *ItemTable) Search(searchQuery string) (items []ItemWithPrice, err error)
- func (table *ItemTable) Update(id uuid.UUID, newItem Item) (updated Item, err error)
- type ItemWithPrice
- type Session
- type SessionQuery
- type SessionTable
- func (table *SessionTable) DeleteByID(id uuid.UUID) (err error)
- func (table *SessionTable) GetSession(sessionID uuid.UUID) (session Session, err error)
- func (table *SessionTable) GetUser(userID uuid.UUID) (session Session, err error)
- func (table *SessionTable) Insert(userID uuid.UUID) (returnedSession Session, err error)
- type Subscription
- type SubscriptionQuery
- type SubscriptionTable
- func (table *SubscriptionTable) Delete(userID, itemID uuid.UUID) (err error)
- func (table *SubscriptionTable) GetByItem(itemID uuid.UUID) (subscriptions []Subscription, err error)
- func (table *SubscriptionTable) GetByUser(userID uuid.UUID) (subscriptions []Subscription, err error)
- func (table *SubscriptionTable) Insert(subscription Subscription) (returnedSubscription Subscription, err error)
- func (table *SubscriptionTable) Update(id uuid.UUID, newSubscription Subscription) (updated Subscription, err error)
- type User
- type UserItem
- type UserItemQuery
- type UserItemTable
- func (table *UserItemTable) DeleteByID(id uuid.UUID) (err error)
- func (table *UserItemTable) GetByUser(userID uuid.UUID) (items []ItemWithPrice, err error)
- func (table *UserItemTable) GetByUserItem(userID uuid.UUID, itemID uuid.UUID) (returnedUserItem UserItem, err error)
- func (table *UserItemTable) Insert(userItem UserItem) (returnedUserItem UserItem, err error)
- func (table *UserItemTable) Update(id uuid.UUID, newUserItem UserItem) (updated UserItem, err error)
- type UserTable
- func (table *UserTable) DeleteByID(id uuid.UUID) (err error)
- func (table *UserTable) GetByEmail(email string) (user User, err error)
- func (table *UserTable) GetByID(id uuid.UUID) (user User, err error)
- func (table *UserTable) Insert(user User) (returnedUser User, err error)
- func (table *UserTable) Login(user User) (found User, err error)
- func (table *UserTable) Update(id uuid.UUID, newUser User) (updated User, err error)
Constants ¶
const ( ItemTableName = "items" ItemLatestView = "items_with_price" )
ItemTableName is the name of the item table in the db ItemLatestView is the name of the item + price view
const ( SessionTableName = "sessions" SessionView = "current_sessions" )
SessionTableName is the name of the session table in the db SessionView is the name of the view where only current sessions are shown
const (
ItemPriceTableName = "item_prices"
)
ItemPriceTableName is the name of the item's price table in the db
const (
SubscriptionTableName = "subscriptions"
)
SubscriptionTableName is the name of the subscription table in the db
const (
UserItemTableName = "user_items"
)
UserItemTableName is the name of the user table in the db
const (
UserTableName = "users"
)
UserTableName is the name of the user table in the db
Variables ¶
This section is empty.
Functions ¶
func LayerInstance ¶
func LayerInstance() *layer
LayerInstance gets the static singleton reference using double check synchronization. It returns the reference to the layer.
Types ¶
type Item ¶
type Item struct {
ID uuid.UUID `valid:"-" json:"id"`
Name string `valid:"required" json:"name"`
Description string `valid:"required" json:"description"`
ImageURL string `valid:"required" json:"image_url" db:"image_url"`
URL string `valid:"required" json:"url"`
Currency string `valid:"required" json:"currency"`
}
Item represents a single row in the ItemTable
type ItemPrice ¶
type ItemPrice struct {
ItemID uuid.UUID `valid:"-" json:"item_id" db:"item_id"`
Time time.Time `valid:"-" json:"time"`
Price int64 `valid:"required" json:"price"`
Available bool `valid:"required" json:"available"`
}
ItemPrice represents a single row in the ItemPriceTable
type ItemPriceQuery ¶
ItemPriceQuery represents all of the rows the item can be queried over
type ItemPriceTable ¶
type ItemPriceTable struct {
// contains filtered or unexported fields
}
ItemPriceTable represents the connection to the db instance
func (*ItemPriceTable) GetAllPrices ¶
func (table *ItemPriceTable) GetAllPrices(itemID uuid.UUID) (itemPrices []ItemPrice, err error)
GetAllPrices gets all prices for a certain item
type ItemTable ¶
type ItemTable struct {
// contains filtered or unexported fields
}
ItemTable represents the connection to the db instance
func (*ItemTable) DeleteByID ¶
DeleteByID permanently removes the item with uuid from table
func (*ItemTable) GetAllWithPrice ¶
func (table *ItemTable) GetAllWithPrice() (items []ItemWithPrice, err error)
GetAllWithPrice gets all items with price from the table
func (*ItemTable) GetWithPrice ¶
func (table *ItemTable) GetWithPrice(id uuid.UUID) (item ItemWithPrice, err error)
GetWithPrice finds an item by id with price
type ItemWithPrice ¶
ItemWithPrice represent the join between Item and ItemPrices
type Session ¶
type Session struct {
ID uuid.UUID `valid:"required" json:"id"`
UserID uuid.UUID `valid:"required" json:"user_id" db:"user_id"`
ExpiresAfter time.Time `valid:"required" json:"expires_after" db:"expires_after"`
JWT string `valid:"required" json:"jwt"`
}
Session represents a single row in the SessionTable
type SessionQuery ¶
SessionQuery represents all of the rows the item can be queried over
type SessionTable ¶
type SessionTable struct {
// contains filtered or unexported fields
}
SessionTable represents the connection to the db instance
func (*SessionTable) DeleteByID ¶
func (table *SessionTable) DeleteByID(id uuid.UUID) (err error)
DeleteByID permanently removes the session with uuid from table
func (*SessionTable) GetSession ¶
func (table *SessionTable) GetSession(sessionID uuid.UUID) (session Session, err error)
GetSession finds a session by id
type Subscription ¶
type Subscription struct {
UserID uuid.UUID `valid:"required" json:"user_id" db:"user_id"`
ItemID uuid.UUID `valid:"required" json:"item_id" db:"json_id"`
Email string `valid:"required" json:"email"`
TargetPrice int64 `valid:"required" json:"target_price" db:"target_price"`
}
Subscription represents a single row in the UserItemTable
type SubscriptionQuery ¶
SubscriptionQuery represents all of the rows the item can be queried over
type SubscriptionTable ¶
type SubscriptionTable struct {
// contains filtered or unexported fields
}
SubscriptionTable represents the connection to the db instance
func (*SubscriptionTable) Delete ¶
func (table *SubscriptionTable) Delete(userID, itemID uuid.UUID) (err error)
Delete permanently removes the subscription with uuid from table
func (*SubscriptionTable) GetByItem ¶
func (table *SubscriptionTable) GetByItem(itemID uuid.UUID) (subscriptions []Subscription, err error)
GetByItem gets all users who follows an item
func (*SubscriptionTable) GetByUser ¶
func (table *SubscriptionTable) GetByUser(userID uuid.UUID) (subscriptions []Subscription, err error)
GetByUser gets all items followed by user with userID
func (*SubscriptionTable) Insert ¶
func (table *SubscriptionTable) Insert(subscription Subscription) (returnedSubscription Subscription, err error)
Insert adds a new item into the table.
func (*SubscriptionTable) Update ¶
func (table *SubscriptionTable) Update(id uuid.UUID, newSubscription Subscription) (updated Subscription, err error)
Update will update the item row with an incoming item
type User ¶
type User struct {
ID uuid.UUID `valid:"-" json:"id"`
Username string `valid:"required" json:"username"`
Email string `valid:"required,email" json:"email"`
Password string `valid:"required" json:"password"`
Created time.Time `valid:"-" json:"created" db:"created"`
LoggedIn time.Time `valid:"-" json:"logged_in" db:"logged_in"`
}
User represents a single row in the UserTable
type UserItem ¶
type UserItem struct {
UserID uuid.UUID `valid:"-" json:"user_id" db:"user_id"`
ItemID uuid.UUID `valid:"-" json:"item_id" db:"item_id"`
}
UserItem represents a single row in the UserItemTable
type UserItemQuery ¶
UserItemQuery represents all of the rows the item can be queried over
type UserItemTable ¶
type UserItemTable struct {
// contains filtered or unexported fields
}
UserItemTable represents the connection to the db instance
func (*UserItemTable) DeleteByID ¶
func (table *UserItemTable) DeleteByID(id uuid.UUID) (err error)
DeleteByID permanently removes the item with uuid from table
func (*UserItemTable) GetByUser ¶
func (table *UserItemTable) GetByUser(userID uuid.UUID) (items []ItemWithPrice, err error)
GetByUser gets all items followed by user with userID
func (*UserItemTable) GetByUserItem ¶
func (table *UserItemTable) GetByUserItem(userID uuid.UUID, itemID uuid.UUID) (returnedUserItem UserItem, err error)
GetByUserItem gets an UserItem by both UserID and ItemID
type UserTable ¶
type UserTable struct {
// contains filtered or unexported fields
}
UserTable represents the connection to the db instance
func (*UserTable) DeleteByID ¶
DeleteByID permanently removes the user with uuid from table
func (*UserTable) GetByEmail ¶
GetByEmail gets an user by email