gorm

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProjectEntityName is the storage entity name for project resources.
	ProjectEntityName = "Project"
	// ApiEntityName is the storage entity name for API resources.
	ApiEntityName = "Api"
	// VersionEntityName is the storage entity name for API version resources.
	VersionEntityName = "Version"
	// SpecEntityName is the storage entity name for API spec resources.
	SpecEntityName = "Spec"
	// SpecRevisionTagEntityName is the storage entity name for API spec revision tag resources.
	SpecRevisionTagEntityName = "SpecRevisionTag"
	// ArtifactEntityName is the storage entity name for artifact resources.
	ArtifactEntityName = "Artifact"
	// BlobEntityName is the storage entity name for blob resources.
	BlobEntityName = "Blob"
)

Variables

This section is empty.

Functions

func NewGormLogger added in v0.3.4

func NewGormLogger(ctx context.Context) logger.Interface

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 [ sqlite3, 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 query.

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) GetRecentSpecRevisions

func (c *Client) GetRecentSpecRevisions(ctx context.Context, offset int32, projectID, apiID, versionID string) *Iterator

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) Put

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

Put puts an entity using the storage client.

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 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