query

package
v0.0.0-...-ef83997 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const APIStringTypeQuery = "queries"

APIStringTypeQuery helps to avoid string literal

View Source
const QueryTableName = "queries"

QueryTableName constant that holds table name of Queries

Variables

This section is empty.

Functions

This section is empty.

Types

type GormQueryRepository

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

GormQueryRepository is the implementation of the storage interface for Queries.

func (*GormQueryRepository) CheckExists

func (r *GormQueryRepository) CheckExists(ctx context.Context, id uuid.UUID) error

CheckExists returns nil if the given ID exists otherwise returns an error

func (*GormQueryRepository) Create

func (r *GormQueryRepository) Create(ctx context.Context, q *Query) error

Create a new query

func (*GormQueryRepository) Delete

func (r *GormQueryRepository) Delete(ctx context.Context, ID uuid.UUID) error

Delete deletes the query with the given id, returns NotFoundError or InternalError

func (*GormQueryRepository) List

func (r *GormQueryRepository) List(ctx context.Context, spaceID uuid.UUID) ([]Query, error)

List all queries in a space

func (*GormQueryRepository) ListByCreator

func (r *GormQueryRepository) ListByCreator(ctx context.Context, spaceID uuid.UUID, creatorID uuid.UUID) ([]Query, error)

ListByCreator all queries in a space by a creator

func (*GormQueryRepository) Load

func (r *GormQueryRepository) Load(ctx context.Context, ID uuid.UUID, spaceID uuid.UUID) (*Query, error)

Load Query in a space

type Query

type Query struct {
	gormsupport.Lifecycle
	ID      uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"` // This is the ID PK field
	SpaceID uuid.UUID `sql:"type:uuid"`
	Creator uuid.UUID `sql:"type:uuid"`
	Title   string
	Fields  string
}

Query describes a single Query

func (Query) GetETagData

func (q Query) GetETagData() []interface{}

GetETagData returns the field values to use to generate the ETag

func (Query) GetLastModified

func (q Query) GetLastModified() time.Time

GetLastModified returns the last modification time

func (Query) TableName

func (q Query) TableName() string

TableName overrides the table name settings in Gorm to force a specific table name in the database.

type Repository

type Repository interface {
	repository.Exister
	Create(ctx context.Context, u *Query) error
	List(ctx context.Context, spaceID uuid.UUID) ([]Query, error)
	ListByCreator(ctx context.Context, spaceID uuid.UUID, creatorID uuid.UUID) ([]Query, error)
	Load(ctx context.Context, queryID uuid.UUID, spaceID uuid.UUID) (*Query, error)
	Delete(ctx context.Context, ID uuid.UUID) error
}

Repository describes interactions with Queries.

func NewQueryRepository

func NewQueryRepository(db *gorm.DB) Repository

NewQueryRepository creates a new storage type.

Directories

Path Synopsis
Package query This package implements a super basic parser that takes a string, converts it to json and constructs an AndExpression of "key == value" expressions of all the fields in the json object this is just a stand-in until we have defined a proper query language
Package query This package implements a super basic parser that takes a string, converts it to json and constructs an AndExpression of "key == value" expressions of all the fields in the json object this is just a stand-in until we have defined a proper query language

Jump to

Keyboard shortcuts

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