datastore

package
v0.1.0-beta0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 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 Driver

type Driver struct {

	// Datastore namespace for multi-tenancy
	Namespace string
	// contains filtered or unexported fields
}

Driver is an implementation of the metadb.Driver interface for Google Cloud Datastore. Call NewDriver to create a new driver instance.

func NewDriver

func NewDriver(ctx context.Context, projectID string, opts ...option.ClientOption) (*Driver, error)

NewDriver creates a new instance of Driver that can be used by metadb.MetaDB. projectID: Google Cloud Platform project ID to use

func (*Driver) Connect

func (d *Driver) Connect(ctx context.Context) error

Connect initiates the database connection.

func (*Driver) CreateStore

func (d *Driver) CreateStore(ctx context.Context, store *m.Store) (*m.Store, error)

CreateStore creates a new store.

func (*Driver) DeleteBlobRef

func (d *Driver) DeleteBlobRef(ctx context.Context, key uuid.UUID) error

DeleteBlobRef implements Driver.DeleteBlobRef.

func (*Driver) DeleteRecord

func (d *Driver) DeleteRecord(ctx context.Context, storeKey, key string) error

DeleteRecord deletes a record with key in store storeKey. It doesn't return error even if the key is not found in the database.

func (*Driver) DeleteStore

func (d *Driver) DeleteStore(ctx context.Context, key string) error

DeleteStore deletes the store with specified key. Returns error if the store has any child records.

func (*Driver) Disconnect

func (d *Driver) Disconnect(ctx context.Context) error

Disconnect terminates the database connection. Make sure to call this method to release resources (e.g. using defer). The MetaDB instance will not be available after Disconnect().

func (*Driver) FindStoreByName

func (d *Driver) FindStoreByName(ctx context.Context, name string) (*m.Store, error)

FindStoreByName finds and fetches a store based on the name (complete match).

func (*Driver) GetBlobRef

func (d *Driver) GetBlobRef(ctx context.Context, key uuid.UUID) (*m.BlobRef, error)

GetBlobRef implements Driver.GetCurrentBlobRef.

func (*Driver) GetCurrentBlobRef

func (d *Driver) GetCurrentBlobRef(ctx context.Context, storeKey, recordKey string) (*m.BlobRef, error)

GetCurrentBlobRef implements Driver.GetCurrentBlobRef.

func (*Driver) GetRecord

func (d *Driver) GetRecord(ctx context.Context, storeKey, key string) (*m.Record, error)

GetRecord fetches and returns a record with key in store storeKey. Returns error if not found.

func (*Driver) GetStore

func (d *Driver) GetStore(ctx context.Context, key string) (*m.Store, error)

GetStore fetches a store based on the key provided. Returns error if the key is not found.

func (*Driver) InsertBlobRef

func (d *Driver) InsertBlobRef(ctx context.Context, blob *m.BlobRef) (*m.BlobRef, error)

InsertBlobRef implements Driver.InsertBlobRef.

func (*Driver) InsertRecord

func (d *Driver) InsertRecord(ctx context.Context, storeKey string, record *m.Record) (*m.Record, error)

InsertRecord creates a new Record in the store specified with storeKey. Returns error if there is already a record with the same key.

func (*Driver) ListBlobRefsByStatus

func (d *Driver) ListBlobRefsByStatus(ctx context.Context, status m.BlobRefStatus, olderThan time.Time) (m.BlobRefCursor, error)

ListBlobRefsByStatus implements Driver.ListBlobRefsByStatus.

func (*Driver) PromoteBlobRefToCurrent

func (d *Driver) PromoteBlobRefToCurrent(ctx context.Context, blob *m.BlobRef) (*m.Record, *m.BlobRef, error)

PromoteBlobRefToCurrent implements Driver.PromoteBlobRefToCurrent.

func (*Driver) RemoveBlobFromRecord

func (d *Driver) RemoveBlobFromRecord(ctx context.Context, storeKey string, recordKey string) (*m.Record, *m.BlobRef, error)

RemoveBlobFromRecord implements Driver.RemoveBlobFromRecord.

func (*Driver) TimestampPrecision

func (d *Driver) TimestampPrecision() time.Duration

TimestampPrecision returns the precision of timestamps stored in Cloud Datastore. Currently it's 1 microsecond. https://cloud.google.com/datastore/docs/concepts/entities#date_and_time

func (*Driver) UpdateBlobRef

func (d *Driver) UpdateBlobRef(ctx context.Context, blob *m.BlobRef) (*m.BlobRef, error)

UpdateBlobRef implements Driver.UpdateBlobRef.

func (*Driver) UpdateRecord

func (d *Driver) UpdateRecord(ctx context.Context, storeKey string, key string, updater m.RecordUpdater) (*m.Record, error)

UpdateRecord updates the record in the store specified with storeKey. Returns error if the store doesn't have a record with the key provided.

Jump to

Keyboard shortcuts

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