db

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 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 Entity

type Entity interface {
	Kind() string
	ID() string
}

Entity represents a single entity stored in Google Cloud Datastore.

type Service

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

Service exposes read and write operations to Google Cloud Datastore.

func NewService

func NewService(projectID string, namespace string) (*Service, error)

NewService creates a new instance of Service.

func (*Service) Count

func (svc *Service) Count(
	ctx context.Context,
	query *datastore.Query) (int, error)

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

func (*Service) Get

func (svc *Service) Get(ctx context.Context, e Entity) error

Get loads the single entity which matches the kind and key of the given object.

func (*Service) Insert

func (svc *Service) Insert(ctx context.Context, e Entity) (alreadyExists bool, err error)

Insert creates a new entity in GCP Datastore or fails with an error.

func (*Service) Query

func (svc *Service) Query(
	ctx context.Context,
	query *datastore.Query,
	entities interface{}) error

Query finds all entities which match the given query.

func (*Service) Upsert

func (svc *Service) Upsert(ctx context.Context, e Entity) error

Upsert creates a new or updates an existing entity in GCP Datastore.

Jump to

Keyboard shortcuts

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