db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package db contains tag related CRUD functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store manages the set of APIs for user access.

func NewStore

func NewStore(log *zap.SugaredLogger, db *sqlx.DB) Store

NewStore constructs a data for api access.

func (Store) Create

func (s Store) Create(ctx context.Context, tag Tag) error

Create inserts a new tag into the database.

func (Store) Delete

func (s Store) Delete(ctx context.Context, tagID string) error

Delete removes a tag from the database.

func (Store) QueryByID

func (s Store) QueryByID(ctx context.Context, tagID string) (Tag, error)

QueryByID gets the specified tag from the database.

func (Store) QueryWorkspaceTags

func (s Store) QueryWorkspaceTags(ctx context.Context, workspaceID string, pageNumber, rowsPerPage int) ([]Tag, error)

QueryWorkspaceTags retrieves a list of existing tag from the database.

func (Store) Tran

func (s Store) Tran(tx sqlx.ExtContext) Store

Tran return new Store with transaction in it.

func (Store) Update

func (s Store) Update(ctx context.Context, tag Tag) error

Update replaces a tag document in the database.

func (Store) WithinTran

func (s Store) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error

WithinTran runs passed function and do commit/rollback at the end.

type Tag

type Tag struct {
	ID          string    `db:"tag_id"`
	Name        string    `db:"name"`
	Wid         string    `db:"wid"`
	DateCreated time.Time `db:"date_created"`
	DateUpdated time.Time `db:"date_updated"`
}

Tag represent the structure we need for moving data between the app and the database.

Jump to

Keyboard shortcuts

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