Documentation ¶
Overview ¶
Package dsent provides a wrapper around the Google Cloud Datastore client to simplify common operations for working with entities in Datastore.
RegisterKind registers a new kind with the given name. It checks if the kind is already registered and panics if it is.
Index ¶
- Variables
- func DecryptMessage(key string, message string) (string, error)
- func EncryptMessage(key string, message string) (string, error)
- func RegisterKind(name string)
- func SetNS(key *datastore.Key, ns string) *datastore.Key
- type DSEnt
- func (db *DSEnt[T]) BatchCreate(ctx context.Context, objs []T) ([]*datastore.Key, []T, error)
- func (db *DSEnt[T]) BatchCreateTx(tx *datastore.Transaction, objs []T) ([]*datastore.PendingKey, []T, error)
- func (db *DSEnt[T]) BatchDelete(ctx context.Context, objs []T) error
- func (db *DSEnt[T]) BatchDeleteTx(tx *datastore.Transaction, objs []T) error
- func (db *DSEnt[T]) BatchGet(ctx context.Context, objs []T) ([]T, error)
- func (db *DSEnt[T]) BatchGetTx(tx *datastore.Transaction, objs []T) ([]T, error)
- func (db *DSEnt[T]) BatchPut(ctx context.Context, objs []T) ([]*datastore.Key, []T, error)
- func (db *DSEnt[T]) BatchPutTx(tx *datastore.Transaction, objs []T) ([]*datastore.PendingKey, []T, error)
- func (db *DSEnt[T]) Close()
- func (db *DSEnt[T]) Create(ctx context.Context, obj T) (*datastore.Key, T, error)
- func (db *DSEnt[T]) CreateTx(tx *datastore.Transaction, obj T) (*datastore.PendingKey, T, error)
- func (db *DSEnt[T]) Delete(ctx context.Context, obj T) error
- func (db *DSEnt[T]) DeleteTx(tx *datastore.Transaction, obj T) error
- func (db *DSEnt[T]) Exists(ctx context.Context, obj T) (bool, error)
- func (db *DSEnt[T]) ExistsTx(ctx context.Context, tx *datastore.Transaction, obj T) (bool, error)
- func (db *DSEnt[T]) Get(ctx context.Context, obj T) (T, error)
- func (db *DSEnt[T]) GetTx(tx *datastore.Transaction, obj T) (T, error)
- func (db *DSEnt[T]) Namespace() string
- func (db *DSEnt[T]) NewQuery() *datastore.Query
- func (db *DSEnt[T]) Put(ctx context.Context, obj T) (*datastore.Key, T, error)
- func (db *DSEnt[T]) PutTx(tx *datastore.Transaction, obj T) (*datastore.PendingKey, T, error)
- func (db *DSEnt[T]) ResolveKey(key *datastore.Key, obj T) error
- func (db *DSEnt[T]) Update(ctx context.Context, obj T, updateFunc func(T) (T, error), ...) (T, error)
- func (db *DSEnt[T]) UpdateTx(tx *datastore.Transaction, obj T, updateFunc func(T) (T, error), ...) (T, error)
- type Object
Constants ¶
This section is empty.
Variables ¶
var ErrConcurrentTransaction = datastore.ErrConcurrentTransaction
ErrConcurrentTransaction is returned when a concurrent transaction is detected.
var ErrKeyChanged = errors.New("key changed during transaction")
ErrKeyChanged is returned when the key of an entity has changed during a transaction.
var ErrNotFound = datastore.ErrNoSuchEntity
ErrNotFound is returned when an entity is not found in Datastore.
var ErrUpdateAbort = errors.New("update aborted")
ErrUpdateAbort is returned when an update operation is aborted.
Functions ¶
func DecryptMessage ¶
DecryptMessage decrypts a message using AES-256 with a arbitrary key. Use it to decrypt the cursor string.
func EncryptMessage ¶
EncryptMessage encrypts a message using AES-256 with a arbitrary key. Use it to encrypt the cursor string.
func RegisterKind ¶
func RegisterKind(name string)
Types ¶
type DSEnt ¶
DSEnt is a generic Datastore entity wrapper that provides methods for performing common operations on entities.
func NewDSEnt ¶
NewDSEnt creates a new instance of DSEnt with the given Datastore client and namespace.
func (*DSEnt[T]) BatchCreate ¶
BatchCreate creates multiple entities in Datastore within a transaction.
func (*DSEnt[T]) BatchCreateTx ¶
func (db *DSEnt[T]) BatchCreateTx(tx *datastore.Transaction, objs []T) ([]*datastore.PendingKey, []T, error)
BatchCreateTx creates multiple entities in Datastore within a transaction.
func (*DSEnt[T]) BatchDelete ¶
BatchDelete is transactional batch delete.
func (*DSEnt[T]) BatchDeleteTx ¶
func (db *DSEnt[T]) BatchDeleteTx(tx *datastore.Transaction, objs []T) error
BatchDeleteTx is used to delete multiple entities in a transaction.
func (*DSEnt[T]) BatchGetTx ¶
func (db *DSEnt[T]) BatchGetTx(tx *datastore.Transaction, objs []T) ([]T, error)
BatchGetTx retrieves multiple entities from Datastore within a transaction.
func (*DSEnt[T]) BatchPutTx ¶
func (db *DSEnt[T]) BatchPutTx(tx *datastore.Transaction, objs []T) ([]*datastore.PendingKey, []T, error)
BatchPutTx saves multiple entities to Datastore within a transaction.
func (*DSEnt[T]) CreateTx ¶
func (db *DSEnt[T]) CreateTx(tx *datastore.Transaction, obj T) (*datastore.PendingKey, T, error)
CreateTx creates a new entity in Datastore within a transaction.
func (*DSEnt[T]) DeleteTx ¶
func (db *DSEnt[T]) DeleteTx(tx *datastore.Transaction, obj T) error
DeleteTx deletes an entity from Datastore within a transaction.
func (*DSEnt[T]) Get ¶
Get retrieves an entity from Datastore and populates the input object with the retrieved data.
func (*DSEnt[T]) GetTx ¶
func (db *DSEnt[T]) GetTx(tx *datastore.Transaction, obj T) (T, error)
GetTx retrieves an entity from Datastore within a transaction and populates the input object with the retrieved data.
func (*DSEnt[T]) PutTx ¶
func (db *DSEnt[T]) PutTx(tx *datastore.Transaction, obj T) (*datastore.PendingKey, T, error)
PutTx saves a single entity to Datastore within a transaction.
func (*DSEnt[T]) ResolveKey ¶
ResolveKey resolves the key of an object by calling its LoadKey method.