db

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo added in v1.9.0

type Repo[T any] struct {
	// contains filtered or unexported fields
}

Repo exposes read and write operations to Google Cloud Datastore.

func NewRepo added in v1.9.0

func NewRepo[T any](
	ctx context.Context,
	projectID,
	namespace,
	kind string,
) (
	*Repo[T],
	error,
)

NewRepo creates a new instance of Repo.

func (*Repo[T]) Count added in v1.9.0

func (r *Repo[T]) Count(
	ctx context.Context,
	query *datastore.Query) (int, error)

Count returns the total count of items resulting from a given query.

func (*Repo[T]) Delete added in v1.9.0

func (r *Repo[T]) Delete(ctx context.Context, key string) error

func (*Repo[T]) Get added in v1.9.0

func (r *Repo[T]) Get(ctx context.Context, key string) (*T, error)

Get loads the single entity which matches the kind and key of the given object. The function will return nil if the entity cannot be found or an error has occurred.

func (*Repo[T]) Insert added in v1.9.0

func (r *Repo[T]) Insert(ctx context.Context, key string, entity *T) (duplicate bool, err error)

Insert creates a new entity in GCP Datastore or fails with an error. The entity should be a struct pointer.

func (*Repo[T]) NewQuery added in v1.9.0

func (r *Repo[T]) NewQuery() *datastore.Query

NewQuery creates a new *datastore.Query for the current kind.

func (*Repo[T]) Query added in v1.9.0

func (r *Repo[T]) Query(
	ctx context.Context,
	query *datastore.Query) ([]*T, error)

Query finds all entities which match the given query.

func (*Repo[T]) Upsert added in v1.9.0

func (r *Repo[T]) Upsert(ctx context.Context, key string, entity *T) error

Upsert creates a new entity or updates an existing one in GCP Datastore. The entity should be a struct pointer.

Jump to

Keyboard shortcuts

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