query

package
v0.0.0-...-ecdd364 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IDatabase

type IDatabase interface {
	Get(dest interface{}, query string, args ...interface{}) error
	Exec(query string, args ...interface{}) (sql.Result, error)
	Select(dest interface{}, query string, args ...interface{}) error
	QueryRowScan(dest interface{}, query string, args ...interface{}) error
}

IDatabase provides data query capabilities.

type IRecord

type IRecord interface {
	Table() string
	PrimaryKey() string
}

IRecord provides table information.

type Q

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

Q is a database wrapper that provides helpful utilities.

func New

func New(db IDatabase) *Q

New returns a new query object.

func (*Q) DeleteAll

func (q *Q) DeleteAll(dest IRecord) (affected int, err error)

DeleteAll removes all records.

func (*Q) DeleteOneByID

func (q *Q) DeleteOneByID(dest IRecord, ID string) (affected int, err error)

DeleteOneByID removes one record by ID.

func (*Q) ExistsByField

func (q *Q) ExistsByField(db IRecord, field string, value string) (found bool, ID string, err error)

ExistsByField determines if a records exists by a specified field and returns the ID.

func (*Q) ExistsByID

func (q *Q) ExistsByID(db IRecord, value string) (found bool, err error)

ExistsByID determines if a records exists by ID.

func (*Q) FindAll

func (q *Q) FindAll(dest IRecord) (total int, err error)

FindAll returns all users.

func (*Q) FindOneByID

func (q *Q) FindOneByID(dest IRecord, ID string) (exists bool, err error)

FindOneByID will find a record by string ID.

Jump to

Keyboard shortcuts

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