postgres

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *sql.DB)

Migrate executes database migrations.

Types

type DB

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

DB is Database backed by PostgreSQL

func NewPostgreSQL

func NewPostgreSQL(conn *url.URL) (*DB, error)

NewPostgreSQL creates a Database backed by PostgreSQL

func (*DB) Close

func (pg *DB) Close() error

Close the DB.

func (*DB) CountArticles

func (pg *DB) CountArticles(status string) (uint, error)

CountArticles count articles

func (*DB) CountArticlesByUser

func (pg *DB) CountArticlesByUser(uid uint, req model.ArticlesPageRequest) (uint, error)

CountArticlesByUser returns total nb of articles of an user from the DB

func (*DB) CountCategoriesByUser

func (pg *DB) CountCategoriesByUser(uid uint) (uint, error)

CountCategoriesByUser returns total nb of categories of an user from the DB

func (*DB) CountDevicesByUser

func (pg *DB) CountDevicesByUser(uid uint) (uint, error)

CountDevicesByUser returns total nb of devices of an user from the DB

func (*DB) CountIncomingWebhooksByUser

func (pg *DB) CountIncomingWebhooksByUser(uid uint) (uint, error)

CountIncomingWebhooksByUser returns total nb of incoming webhooks of an user from the DB

func (*DB) CountOutgoingWebhooksByUser

func (pg *DB) CountOutgoingWebhooksByUser(uid uint) (uint, error)

CountOutgoingWebhooksByUser returns total nb of outgoing webhooks of an user from the DB

func (*DB) CountUsers

func (pg *DB) CountUsers() (uint, error)

CountUsers count users

func (*DB) CreateArticleForUser

func (pg *DB) CreateArticleForUser(uid uint, form model.ArticleCreateForm) (*model.Article, error)

CreateArticleForUser creates an article into the DB

func (*DB) CreateCategoryForUser

func (pg *DB) CreateCategoryForUser(uid uint, form model.CategoryCreateForm) (*model.Category, error)

CreateCategoryForUser create a category for an user

func (*DB) CreateDevice

func (pg *DB) CreateDevice(device model.Device) (*model.Device, error)

CreateDevice create a device

func (*DB) CreateIncomingWebhookForUser

func (pg *DB) CreateIncomingWebhookForUser(uid uint, form model.IncomingWebhookCreateForm) (*model.IncomingWebhook, error)

CreateIncomingWebhookForUser creates an incoming webhook for a user

func (*DB) CreateOrUpdateUser

func (pg *DB) CreateOrUpdateUser(user model.User) (*model.User, error)

CreateOrUpdateUser creates or updates a user into the DB

func (*DB) CreateOutgoingWebhookForUser

func (pg *DB) CreateOutgoingWebhookForUser(uid uint, form model.OutgoingWebhookCreateForm) (*model.OutgoingWebhook, error)

CreateOutgoingWebhookForUser creates an outgoing webhook into the DB

func (*DB) CreateProperties

func (pg *DB) CreateProperties(properties model.Properties) (*model.Properties, error)

CreateProperties update properties (create a new revision)

func (*DB) DeleteAllReadArticlesByUser

func (pg *DB) DeleteAllReadArticlesByUser(uid uint) (int64, error)

DeleteAllReadArticlesByUser remove all read articles from the DB

func (*DB) DeleteArticle

func (pg *DB) DeleteArticle(id uint) error

DeleteArticle remove an article from the DB

func (*DB) DeleteCategoriesByUser

func (pg *DB) DeleteCategoriesByUser(uid uint, ids []uint) (int64, error)

DeleteCategoriesByUser removes categories from the DB

func (*DB) DeleteCategoryByUser

func (pg *DB) DeleteCategoryByUser(uid, id uint) error

DeleteCategoryByUser removes an category from the DB

func (*DB) DeleteDevice

func (pg *DB) DeleteDevice(id uint) error

DeleteDevice removes an device from the DB

func (*DB) DeleteDevicesByUser

func (pg *DB) DeleteDevicesByUser(uid uint, ids []uint) (int64, error)

DeleteDevicesByUser removes devices from the DB

func (*DB) DeleteInactiveDevicesOlderThan

func (pg *DB) DeleteInactiveDevicesOlderThan(delay time.Duration) (int64, error)

DeleteInactiveDevicesOlderThan remove inactive devices from the DB

func (*DB) DeleteIncomingWebhookByUser

func (pg *DB) DeleteIncomingWebhookByUser(uid, id uint) error

DeleteIncomingWebhookByUser removes an inboundService from the DB

func (*DB) DeleteIncomingWebhooksByUser

func (pg *DB) DeleteIncomingWebhooksByUser(uid uint, ids []uint) (int64, error)

DeleteIncomingWebhooksByUser removes incoming webhooks from the DB

func (*DB) DeleteOutgoingWebhookByUser

func (pg *DB) DeleteOutgoingWebhookByUser(uid, id uint) error

DeleteOutgoingWebhookByUser removes an outgoing webhook from the DB

func (*DB) DeleteOutgoingWebhooksByUser

func (pg *DB) DeleteOutgoingWebhooksByUser(uid uint, ids []uint) (int64, error)

DeleteOutgoingWebhooksByUser removes outgoing webhooks from the DB

func (*DB) DeleteReadArticlesOlderThan

func (pg *DB) DeleteReadArticlesOlderThan(delay time.Duration) (int64, error)

DeleteReadArticlesOlderThan remove old articles from the DB

func (*DB) DeleteUser

func (pg *DB) DeleteUser(user model.User) error

DeleteUser removes an user from the DB

func (*DB) GetArticleByID

func (pg *DB) GetArticleByID(id uint) (*model.Article, error)

GetArticleByID returns an article by its ID from DB

func (*DB) GetCategoriesByUser

func (pg *DB) GetCategoriesByUser(uid uint) ([]model.Category, error)

GetCategoriesByUser returns categories of an user from DB

func (*DB) GetCategoryByID

func (pg *DB) GetCategoryByID(id uint) (*model.Category, error)

GetCategoryByID returns a category from the DB

func (*DB) GetCategoryByUserAndTitle

func (pg *DB) GetCategoryByUserAndTitle(uid uint, title string) (*model.Category, error)

GetCategoryByUserAndTitle returns a category of an user form the DB

func (*DB) GetDeviceByID

func (pg *DB) GetDeviceByID(id uint) (*model.Device, error)

GetDeviceByID get a device from the DB

func (*DB) GetDeviceByUserAndKey

func (pg *DB) GetDeviceByUserAndKey(uid uint, key string) (*model.Device, error)

GetDeviceByUserAndKey get an device from the DB Only exposed for testing purpose!

func (*DB) GetDevicesByUser

func (pg *DB) GetDevicesByUser(uid uint) ([]model.Device, error)

GetDevicesByUser returns devices of an user from DB

func (*DB) GetIncomingWebhookByID

func (pg *DB) GetIncomingWebhookByID(id uint) (*model.IncomingWebhook, error)

GetIncomingWebhookByID get an incoming webhook from the DB

func (*DB) GetIncomingWebhookByToken

func (pg *DB) GetIncomingWebhookByToken(token string) (*model.IncomingWebhook, error)

GetIncomingWebhookByToken find an incoming webhook by token form the DB (last usage is updated!)

func (*DB) GetIncomingWebhookByUserAndAlias

func (pg *DB) GetIncomingWebhookByUserAndAlias(uid uint, alias string) (*model.IncomingWebhook, error)

GetIncomingWebhookByUserAndAlias returns incoming webhook of an user by its alias

func (*DB) GetIncomingWebhooksByUser

func (pg *DB) GetIncomingWebhooksByUser(uid uint) ([]model.IncomingWebhook, error)

GetIncomingWebhooksByUser returns incoming webhooks of an user from DB

func (*DB) GetOutgoingWebhookByID

func (pg *DB) GetOutgoingWebhookByID(id uint) (*model.OutgoingWebhook, error)

GetOutgoingWebhookByID get an outgoing webhook from the DB

func (*DB) GetOutgoingWebhookByUserAndAlias

func (pg *DB) GetOutgoingWebhookByUserAndAlias(uid uint, alias *string) (*model.OutgoingWebhook, error)

GetOutgoingWebhookByUserAndAlias get an outgoing webhook from the DB. Default outgoing webhook is returned if alias is nil.

func (*DB) GetOutgoingWebhooksByUser

func (pg *DB) GetOutgoingWebhooksByUser(uid uint) ([]model.OutgoingWebhook, error)

GetOutgoingWebhooksByUser returns outgoing webhooks of an user from DB

func (*DB) GetPaginatedArticlesByUser

func (pg *DB) GetPaginatedArticlesByUser(uid uint, req model.ArticlesPageRequest) (*model.ArticlesPageResponse, error)

GetPaginatedArticlesByUser returns a paginated list of user's articles from the DB

func (*DB) GetProperties

func (pg *DB) GetProperties() (*model.Properties, error)

GetProperties get last revision of properties from the DB

func (*DB) GetUserByID

func (pg *DB) GetUserByID(id uint) (*model.User, error)

GetUserByID returns a user by its ID from DB

func (*DB) GetUserByUsername

func (pg *DB) GetUserByUsername(username string) (*model.User, error)

GetUserByUsername returns user by its username from DB

func (*DB) ManageOutgoingWebhookSecrets

func (pg *DB) ManageOutgoingWebhookSecrets(ctx context.Context, provider secret.EngineProvider, action secret.Action) (uint, error)

ManageOutgoingWebhookSecrets manage protection of outgoing webhook secrets

func (*DB) MarkAllArticlesAsReadByUser

func (pg *DB) MarkAllArticlesAsReadByUser(uid uint, status string, categoryID *uint) (int64, error)

MarkAllArticlesAsReadByUser set status to read for all user's articles of a specific status and category

func (*DB) UpdateArticleForUser

func (pg *DB) UpdateArticleForUser(uid uint, form model.ArticleUpdateForm) (*model.Article, error)

UpdateArticleForUser updates an article into the DB

func (*DB) UpdateCategoryForUser

func (pg *DB) UpdateCategoryForUser(uid uint, form model.CategoryUpdateForm) (*model.Category, error)

UpdateCategoryForUser update a category for an user

func (*DB) UpdateIncomingWebhookForUser

func (pg *DB) UpdateIncomingWebhookForUser(uid uint, form model.IncomingWebhookUpdateForm) (*model.IncomingWebhook, error)

UpdateIncomingWebhookForUser updates an incoming webhook for a user

func (*DB) UpdateOutgoingWebhookForUser

func (pg *DB) UpdateOutgoingWebhookForUser(uid uint, form model.OutgoingWebhookUpdateForm) (*model.OutgoingWebhook, error)

UpdateOutgoingWebhookForUser update an outgoing webhook of the DB

Jump to

Keyboard shortcuts

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