postgres

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToTSQuery added in v0.10.0

func ToTSQuery(input string) string

ToTSQuery converts input to another string that can be safely used for ts_query

Types

type EventStorage added in v0.16.0

type EventStorage struct {
	// contains filtered or unexported fields
}

EventStorage contains read and write operations for Audit Events

func NewEventStorage added in v0.16.0

func NewEventStorage(trx *dbx.Trx) *EventStorage

NewEventStorage creates a new inmemory EventStorage

func (*EventStorage) Add added in v0.16.0

func (e *EventStorage) Add(clientIP, name string) (*models.Event, error)

Add stores a new event

func (*EventStorage) GetByID added in v0.16.0

func (e *EventStorage) GetByID(id int) (*models.Event, error)

GetByID returns the event with the specified id

func (*EventStorage) SetCurrentTenant added in v0.16.0

func (e *EventStorage) SetCurrentTenant(tenant *models.Tenant)

SetCurrentTenant to current context

func (*EventStorage) SetCurrentUser added in v0.16.0

func (e *EventStorage) SetCurrentUser(user *models.User)

SetCurrentUser to current context

type NotificationStorage added in v0.10.0

type NotificationStorage struct {
	// contains filtered or unexported fields
}

NotificationStorage contains read and write operations for notifications

func NewNotificationStorage added in v0.10.0

func NewNotificationStorage(trx *dbx.Trx) *NotificationStorage

NewNotificationStorage creates a new NotificationStorage

func (*NotificationStorage) GetActiveNotifications added in v0.10.0

func (s *NotificationStorage) GetActiveNotifications() ([]*models.Notification, error)

GetActiveNotifications returns all unread notifications and last 30 days of read notifications

func (*NotificationStorage) GetNotification added in v0.10.0

func (s *NotificationStorage) GetNotification(id int) (*models.Notification, error)

GetNotification returns notification by id

func (*NotificationStorage) Insert added in v0.10.0

func (s *NotificationStorage) Insert(user *models.User, title, link string, postID int) (*models.Notification, error)

Insert notification for given user

func (*NotificationStorage) MarkAllAsRead added in v0.10.0

func (s *NotificationStorage) MarkAllAsRead() error

MarkAllAsRead of current user

func (*NotificationStorage) MarkAsRead added in v0.10.0

func (s *NotificationStorage) MarkAsRead(id int) error

MarkAsRead given id of current user

func (*NotificationStorage) SetCurrentTenant added in v0.10.0

func (s *NotificationStorage) SetCurrentTenant(tenant *models.Tenant)

SetCurrentTenant to current context

func (*NotificationStorage) SetCurrentUser added in v0.10.0

func (s *NotificationStorage) SetCurrentUser(user *models.User)

SetCurrentUser to current context

func (*NotificationStorage) TotalUnread added in v0.10.0

func (s *NotificationStorage) TotalUnread() (int, error)

TotalUnread returns the number of unread notifications for current user

type PostStorage added in v0.15.0

type PostStorage struct {
	// contains filtered or unexported fields
}

PostStorage contains read and write operations for posts

func NewPostStorage added in v0.15.0

func NewPostStorage(trx *dbx.Trx, ctx storage.Context) *PostStorage

NewPostStorage creates a new PostStorage

func (*PostStorage) Add added in v0.15.0

func (s *PostStorage) Add(title, description string) (*models.Post, error)

Add a new post in the database

func (*PostStorage) AddComment added in v0.15.0

func (s *PostStorage) AddComment(post *models.Post, content string) (int, error)

AddComment places a new comment on an post

func (*PostStorage) AddSubscriber added in v0.15.0

func (s *PostStorage) AddSubscriber(post *models.Post, user *models.User) error

AddSubscriber adds user to the post list of subscribers

func (*PostStorage) AddVote added in v0.16.0

func (s *PostStorage) AddVote(post *models.Post, user *models.User) error

AddVote adds user to post list of votes

func (*PostStorage) CountPerStatus added in v0.15.0

func (s *PostStorage) CountPerStatus() (map[models.PostStatus]int, error)

CountPerStatus returns total number of posts per status

func (*PostStorage) DeleteComment added in v0.16.0

func (s *PostStorage) DeleteComment(id int) error

DeleteComment by its id

func (*PostStorage) GetActiveSubscribers added in v0.15.0

func (s *PostStorage) GetActiveSubscribers(number int, channel models.NotificationChannel, event models.NotificationEvent) ([]*models.User, error)

GetActiveSubscribers based on input and settings

func (*PostStorage) GetAll added in v0.15.0

func (s *PostStorage) GetAll() ([]*models.Post, error)

GetAll returns all tenant posts

func (*PostStorage) GetAttachments added in v0.18.0

func (s *PostStorage) GetAttachments(post *models.Post, comment *models.Comment) ([]string, error)

GetAttachments for given post or comment

func (*PostStorage) GetByID added in v0.15.0

func (s *PostStorage) GetByID(postID int) (*models.Post, error)

GetByID returns post by given id

func (*PostStorage) GetByNumber added in v0.15.0

func (s *PostStorage) GetByNumber(number int) (*models.Post, error)

GetByNumber returns post by tenant and number

func (*PostStorage) GetBySlug added in v0.15.0

func (s *PostStorage) GetBySlug(slug string) (*models.Post, error)

GetBySlug returns post by tenant and slug

func (*PostStorage) GetCommentByID added in v0.15.0

func (s *PostStorage) GetCommentByID(id int) (*models.Comment, error)

GetCommentByID returns a comment by given ID

func (*PostStorage) GetCommentsByPost added in v0.15.0

func (s *PostStorage) GetCommentsByPost(post *models.Post) ([]*models.Comment, error)

GetCommentsByPost returns all comments from given post

func (*PostStorage) IsReferenced added in v0.15.0

func (s *PostStorage) IsReferenced(post *models.Post) (bool, error)

IsReferenced returns true if another post is referencing given post

func (*PostStorage) ListVotes added in v0.17.0

func (s *PostStorage) ListVotes(post *models.Post, limit int) ([]*models.Vote, error)

ListVotes returns a list of all votes on given post

func (*PostStorage) MarkAsDuplicate added in v0.15.0

func (s *PostStorage) MarkAsDuplicate(post *models.Post, original *models.Post) error

MarkAsDuplicate set post as a duplicate of another post

func (*PostStorage) RemoveSubscriber added in v0.15.0

func (s *PostStorage) RemoveSubscriber(post *models.Post, user *models.User) error

RemoveSubscriber removes user from post list of subscribers

func (*PostStorage) RemoveVote added in v0.16.0

func (s *PostStorage) RemoveVote(post *models.Post, user *models.User) error

RemoveVote removes user from post list of votes

func (*PostStorage) Search added in v0.15.0

func (s *PostStorage) Search(query, view, limit string, tags []string) ([]*models.Post, error)

Search existing posts based on input

func (*PostStorage) SetAttachments added in v0.18.0

func (s *PostStorage) SetAttachments(post *models.Post, comment *models.Comment, attachments []*models.ImageUpload) error

SetAttachments on given post or comment

func (*PostStorage) SetCurrentTenant added in v0.15.0

func (s *PostStorage) SetCurrentTenant(tenant *models.Tenant)

SetCurrentTenant to current context

func (*PostStorage) SetCurrentUser added in v0.15.0

func (s *PostStorage) SetCurrentUser(user *models.User)

SetCurrentUser to current context

func (*PostStorage) SetResponse added in v0.15.0

func (s *PostStorage) SetResponse(post *models.Post, text string, status models.PostStatus) error

SetResponse changes current post response

func (*PostStorage) Update added in v0.15.0

func (s *PostStorage) Update(post *models.Post, title, description string) (*models.Post, error)

Update given post

func (*PostStorage) UpdateComment added in v0.15.0

func (s *PostStorage) UpdateComment(id int, content string) error

UpdateComment with given ID and content

func (*PostStorage) VotedBy added in v0.16.0

func (s *PostStorage) VotedBy() ([]int, error)

VotedBy returns a list of Post ID voted by given user

type TagStorage added in v0.8.0

type TagStorage struct {
	// contains filtered or unexported fields
}

TagStorage contains read and write operations for tags

func NewTagStorage added in v0.8.0

func NewTagStorage(trx *dbx.Trx) *TagStorage

NewTagStorage creates a new TagStorage

func (*TagStorage) Add added in v0.8.0

func (s *TagStorage) Add(name, color string, isPublic bool) (*models.Tag, error)

Add creates a new tag with given input

func (*TagStorage) AssignTag added in v0.8.0

func (s *TagStorage) AssignTag(tag *models.Tag, post *models.Post) error

AssignTag adds a tag to an post

func (*TagStorage) Delete added in v0.8.0

func (s *TagStorage) Delete(tag *models.Tag) error

Delete a tag by its id

func (*TagStorage) GetAll added in v0.8.0

func (s *TagStorage) GetAll() ([]*models.Tag, error)

GetAll returns all tags

func (*TagStorage) GetAssigned added in v0.8.0

func (s *TagStorage) GetAssigned(post *models.Post) ([]*models.Tag, error)

GetAssigned returns all tags assigned to given post

func (*TagStorage) GetBySlug added in v0.8.0

func (s *TagStorage) GetBySlug(slug string) (*models.Tag, error)

GetBySlug returns tag by given slug

func (*TagStorage) SetCurrentTenant added in v0.8.0

func (s *TagStorage) SetCurrentTenant(tenant *models.Tenant)

SetCurrentTenant to current context

func (*TagStorage) SetCurrentUser added in v0.8.0

func (s *TagStorage) SetCurrentUser(user *models.User)

SetCurrentUser to current context

func (*TagStorage) UnassignTag added in v0.8.0

func (s *TagStorage) UnassignTag(tag *models.Tag, post *models.Post) error

UnassignTag removes a tag from an post

func (*TagStorage) Update added in v0.8.0

func (s *TagStorage) Update(tag *models.Tag, name, color string, isPublic bool) (*models.Tag, error)

Update a tag with given input

type TenantStorage

type TenantStorage struct {
	// contains filtered or unexported fields
}

TenantStorage contains read and write operations for tenants

func NewTenantStorage

func NewTenantStorage(trx *dbx.Trx) *TenantStorage

NewTenantStorage creates a new TenantStorage

func (*TenantStorage) Activate added in v0.6.0

func (s *TenantStorage) Activate(id int) error

Activate given tenant

func (*TenantStorage) Add

func (s *TenantStorage) Add(name string, subdomain string, status int) (*models.Tenant, error)

Add given tenant to tenant list

func (*TenantStorage) Current added in v0.18.0

func (s *TenantStorage) Current() *models.Tenant

Current returns current context tenant

func (*TenantStorage) FindVerificationByKey added in v0.6.0

func (s *TenantStorage) FindVerificationByKey(kind models.EmailVerificationKind, key string) (*models.EmailVerification, error)

FindVerificationByKey based on current tenant

func (*TenantStorage) First

func (s *TenantStorage) First() (*models.Tenant, error)

First returns first tenant

func (*TenantStorage) GetByDomain

func (s *TenantStorage) GetByDomain(domain string) (*models.Tenant, error)

GetByDomain returns a tenant based on its domain

func (*TenantStorage) GetOAuthConfigByProvider added in v0.15.0

func (s *TenantStorage) GetOAuthConfigByProvider(provider string) (*models.OAuthConfig, error)

GetOAuthConfigByProvider returns a custom OAuth configuration by provider name

func (*TenantStorage) IsCNAMEAvailable added in v0.8.0

func (s *TenantStorage) IsCNAMEAvailable(cname string) (bool, error)

IsCNAMEAvailable returns true if cname is available to use

func (*TenantStorage) IsSubdomainAvailable

func (s *TenantStorage) IsSubdomainAvailable(subdomain string) (bool, error)

IsSubdomainAvailable returns true if subdomain is available to use

func (*TenantStorage) ListOAuthConfig added in v0.15.0

func (s *TenantStorage) ListOAuthConfig() ([]*models.OAuthConfig, error)

ListOAuthConfig returns a list of all custom OAuth provider for current tenant

func (*TenantStorage) SaveOAuthConfig added in v0.15.0

func (s *TenantStorage) SaveOAuthConfig(config *models.CreateEditOAuthConfig) error

SaveOAuthConfig saves given config into database

func (*TenantStorage) SaveVerificationKey added in v0.6.0

func (s *TenantStorage) SaveVerificationKey(key string, duration time.Duration, request models.NewEmailVerification) error

SaveVerificationKey used by email verification process

func (*TenantStorage) SetCurrentTenant added in v0.6.0

func (s *TenantStorage) SetCurrentTenant(tenant *models.Tenant)

SetCurrentTenant to current context

func (*TenantStorage) SetCurrentUser added in v0.8.0

func (s *TenantStorage) SetCurrentUser(user *models.User)

SetCurrentUser to current context

func (*TenantStorage) SetKeyAsVerified added in v0.6.0

func (s *TenantStorage) SetKeyAsVerified(key string) error

SetKeyAsVerified so that it cannot be used anymore

func (*TenantStorage) UpdateAdvancedSettings added in v0.13.0

func (s *TenantStorage) UpdateAdvancedSettings(settings *models.UpdateTenantAdvancedSettings) error

UpdateAdvancedSettings of current tenant

func (*TenantStorage) UpdateBillingSettings added in v0.18.0

func (s *TenantStorage) UpdateBillingSettings(billing *models.TenantBilling) error

UpdateBillingSettings of current tenant

func (*TenantStorage) UpdatePrivacy added in v0.12.0

func (s *TenantStorage) UpdatePrivacy(settings *models.UpdateTenantPrivacy) error

UpdatePrivacy settings of current tenant

func (*TenantStorage) UpdateSettings added in v0.4.0

func (s *TenantStorage) UpdateSettings(settings *models.UpdateTenantSettings) error

UpdateSettings of current tenant

type UserStorage

type UserStorage struct {
	// contains filtered or unexported fields
}

UserStorage is used for user operations using a Postgres database

func NewUserStorage

func NewUserStorage(trx *dbx.Trx, ctx storage.Context) *UserStorage

NewUserStorage creates a new UserStorage

func (*UserStorage) Block added in v0.17.0

func (s *UserStorage) Block(userID int) error

Block a given user from using Fider

func (*UserStorage) ChangeEmail added in v0.9.0

func (s *UserStorage) ChangeEmail(userID int, email string) error

ChangeEmail of given user

func (*UserStorage) ChangeRole added in v0.7.0

func (s *UserStorage) ChangeRole(userID int, role models.Role) error

ChangeRole of given user

func (*UserStorage) Count added in v0.18.0

func (s *UserStorage) Count() (int, error)

Count returns the total number of registered users

func (*UserStorage) Delete added in v0.13.0

func (s *UserStorage) Delete() error

Delete removes current user personal data and mark it as deleted

func (*UserStorage) GetAll added in v0.7.0

func (s *UserStorage) GetAll() ([]*models.User, error)

GetAll return all users of current tenant

func (*UserStorage) GetByAPIKey added in v0.15.0

func (s *UserStorage) GetByAPIKey(apiKey string) (*models.User, error)

GetByAPIKey returns a user based on its API key

func (*UserStorage) GetByEmail

func (s *UserStorage) GetByEmail(email string) (*models.User, error)

GetByEmail returns a user based on given email

func (*UserStorage) GetByID

func (s *UserStorage) GetByID(userID int) (*models.User, error)

GetByID returns a user based on given id

func (*UserStorage) GetByProvider added in v0.4.0

func (s *UserStorage) GetByProvider(provider string, uid string) (*models.User, error)

GetByProvider returns a user based on provider details

func (*UserStorage) GetUserSettings added in v0.10.0

func (s *UserStorage) GetUserSettings() (map[string]string, error)

GetUserSettings returns current user's settings

func (*UserStorage) HasSubscribedTo added in v0.10.0

func (s *UserStorage) HasSubscribedTo(postID int) (bool, error)

HasSubscribedTo returns true if current user is receiving notification from specific post

func (*UserStorage) RegenerateAPIKey added in v0.15.0

func (s *UserStorage) RegenerateAPIKey() (string, error)

RegenerateAPIKey generates a new API Key and returns it

func (*UserStorage) Register

func (s *UserStorage) Register(user *models.User) error

Register creates a new user based on given information

func (*UserStorage) RegisterProvider

func (s *UserStorage) RegisterProvider(userID int, provider *models.UserProvider) error

RegisterProvider adds given provider to userID

func (*UserStorage) SetCurrentTenant added in v0.8.0

func (s *UserStorage) SetCurrentTenant(tenant *models.Tenant)

SetCurrentTenant to current context

func (*UserStorage) SetCurrentUser added in v0.8.0

func (s *UserStorage) SetCurrentUser(user *models.User)

SetCurrentUser to current context

func (*UserStorage) Unblock added in v0.17.0

func (s *UserStorage) Unblock(userID int) error

Unblock a given user so that they can use Fider again

func (*UserStorage) Update added in v0.6.0

func (s *UserStorage) Update(settings *models.UpdateUserSettings) error

Update user profile

func (*UserStorage) UpdateSettings added in v0.10.0

func (s *UserStorage) UpdateSettings(settings map[string]string) error

UpdateSettings of given user

Jump to

Keyboard shortcuts

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