favorite

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB implements the Store interface using a postgres database.

func NewDB

func NewDB(ctx context.Context, db *sql.DB) (*DB, error)

NewDB will create a DB backend from a sql.DB. An error will be returned if statements fail to prepare.

func (*DB) FindAll

func (db *DB) FindAll(ctx context.Context, userID string, filter []assignment.TargetType) ([]assignment.Target, error)

func (*DB) Set

func (db *DB) Set(ctx context.Context, userID string, tgt assignment.Target) error

Set will store the target as a favorite of the given user. Must be authorized as System or the same user.

func (*DB) SetTx added in v0.23.0

func (db *DB) SetTx(ctx context.Context, tx *sql.Tx, userID string, tgt assignment.Target) error

SetTx will store the target as a favorite of the given user. Must be authorized as System or the same user.

func (*DB) Unset

func (db *DB) Unset(ctx context.Context, userID string, tgt assignment.Target) error

Unset will remove the target as a favorite of the given user. Must be authorized as System or the same user.

type Store

type Store interface {
	// Set will set a target as a favorite for the given userID. It is safe to call multiple times.
	Set(ctx context.Context, userID string, tgt assignment.Target) error

	// SetTx will set a target as a favorite for the given userID. It is safe to call multiple times.
	SetTx(ctx context.Context, tx *sql.Tx, userID string, tgt assignment.Target) error

	// Unset will unset a target as a favorite for the given userID. It is safe to call multiple times.
	Unset(ctx context.Context, userID string, tgt assignment.Target) error

	FindAll(ctx context.Context, userID string, filter []assignment.TargetType) ([]assignment.Target, error)
}

Store allows the lookup and management of Favorites.

Jump to

Keyboard shortcuts

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