gorm

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a connection to a storage provider.

func NewClient

func NewClient(ctx context.Context, driver, dsn string) (*Client, error)

NewClient creates a new database session using the provided driver and data source name. Driver must be one of [ postgres, cloudsqlpostgres ]. DSN format varies per database driver.

PostgreSQL DSN Reference: See "Connection Strings" at https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING SQLite DSN Reference: See "URI filename examples" at https://www.sqlite.org/c3ref/open.html

func (*Client) Close

func (c *Client) Close()

Close closes a database session.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, q *Query) error

Delete deletes all entities matching a key.

func (*Client) Get

func (c *Client) Get(ctx context.Context, k *Key, v interface{}) error

Get gets an entity using the storage client.

func (*Client) IsNotFound

func (c *Client) IsNotFound(err error) bool

IsNotFound returns true if an error is due to an entity not being found.

func (*Client) NewKey

func (c *Client) NewKey(kind, name string) *Key

NewKey creates a new storage key.

func (*Client) NewQuery

func (c *Client) NewQuery(kind string) *Query

NewQuery creates a new query.

func (*Client) PutDocument

func (c *Client) PutDocument(ctx context.Context, r *models.Document) error

Put puts an entity using the storage client.

func (*Client) Raw

func (c *Client) Raw(ctx context.Context, target RawRows, sql string, values ...interface{}) error

func (*Client) Run

func (c *Client) Run(ctx context.Context, q *Query) *Iterator

Run runs a query using the storage client, returning an iterator.

type Iterator

type Iterator struct {
	Client *Client
	Values interface{}
	Index  int
	Cursor string
}

Iterator can be used to iterate through results of a query.

func (*Iterator) GetCursor

func (it *Iterator) GetCursor() (string, error)

GetCursor gets the cursor for the next page of results.

func (*Iterator) Next

func (it *Iterator) Next(v interface{}) (*Key, error)

Next gets the next value from the iterator.

type Key

type Key struct {
	Kind string
	Name string
}

Key represents a key in a storage provider

func (*Key) String

func (k *Key) String() string

type Query

type Query struct {
	Kind         string
	Offset       int
	Order        string
	Requirements []*Requirement
}

Query represents a query in a storage provider.

func (*Query) ApplyOffset

func (q *Query) ApplyOffset(offset int32) *Query

func (*Query) Descending

func (q *Query) Descending(field string) *Query

func (*Query) Require

func (q *Query) Require(name string, value interface{}) *Query

Require adds a filter to a query that requires a field to have a specified value.

type RawRows

type RawRows interface {
	Append(rows *sql.Rows) error
}

type Requirement

type Requirement struct {
	Name  string
	Value interface{}
}

Requirement adds an equality filter to a query.

Jump to

Keyboard shortcuts

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