A transaction is a set of Datastore operations on one or more entities. Each transaction is guaranteed to be atomic, which means that transactions are never partially applied. Either all of the operations in the transaction are applied, or none of them are applied.
Transactions Reference
{Request}
Inheritance
DatastoreRequest
>
Transaction
Package
@google-cloud/datastore
Constructors
(constructor)(datastore, options)
constructor(datastore: Datastore, options?: TransactionOptions);
Constructs a new instance of the Transaction
class
Parameters
Properties
modifiedEntities_
modifiedEntities_: ModifiedEntities;
Property Value
Type | Description |
ModifiedEntities | |
namespace
Property Value
readOnly
Property Value
request
Property Value
skipCommit
Property Value
Methods
commit(gaxOptions)
commit(gaxOptions?: CallOptions): Promise<CommitResponse>;
Parameter
Name | Description |
gaxOptions |
CallOptions
|
Returns
Type | Description |
Promise<CommitResponse> | |
commit(callback)
commit(callback: CommitCallback): void;
Parameter
Name | Description |
callback |
CommitCallback
|
Returns
commit(gaxOptions, callback)
commit(gaxOptions: CallOptions, callback: CommitCallback): void;
Parameters
Name | Description |
gaxOptions |
CallOptions
|
callback |
CommitCallback
|
Returns
createQuery(kind)
createQuery(kind?: string): Query;
Parameter
Name | Description |
kind |
string
|
Returns
createQuery(kind)
createQuery(kind?: string[]): Query;
Parameter
Name | Description |
kind |
string[]
|
Returns
createQuery(namespace, kind)
createQuery(namespace: string, kind: string): Query;
Parameters
Name | Description |
namespace |
string
|
kind |
string
|
Returns
createQuery(namespace, kind)
createQuery(namespace: string, kind: string[]): Query;
Parameters
Name | Description |
namespace |
string
|
kind |
string[]
|
Returns
delete(entities)
delete(entities?: Entities): any;
Delete all entities identified with the specified key(s) in the current transaction.
Parameter
Name | Description |
entities |
Entities
|
Returns
insert(entities)
insert(entities: Entities): void;
Maps to , forcing the method to be insert
.
Parameter
Name | Description |
entities |
Entities
Datastore key object(s).
|
Returns
rollback(callback)
rollback(callback: RollbackCallback): void;
Parameter
Name | Description |
callback |
RollbackCallback
|
Returns
rollback(gaxOptions)
rollback(gaxOptions?: CallOptions): Promise<RollbackResponse>;
Parameter
Name | Description |
gaxOptions |
CallOptions
|
Returns
Type | Description |
Promise<RollbackResponse> | |
rollback(gaxOptions, callback)
rollback(gaxOptions: CallOptions, callback: RollbackCallback): void;
Parameters
Name | Description |
gaxOptions |
CallOptions
|
callback |
RollbackCallback
|
Returns
run(options)
run(options?: RunOptions): Promise<RunResponse>;
Parameter
Name | Description |
options |
RunOptions
|
Returns
Type | Description |
Promise<RunResponse> | |
run(callback)
run(callback: RunCallback): void;
Parameter
Name | Description |
callback |
RunCallback
|
Returns
run(options, callback)
run(options: RunOptions, callback: RunCallback): void;
Parameters
Name | Description |
options |
RunOptions
|
callback |
RunCallback
|
Returns
save(entities)
save(entities: Entities): void;
Insert or update the specified object(s) in the current transaction. If a key is incomplete, its associated object is inserted and the original Key object is updated to contain the generated ID.
This method will determine the correct Datastore method to execute (upsert
, insert
, or update
) by using the key(s) provided. For example, if you provide an incomplete key (one without an ID), the request will create a new entity and have its ID automatically assigned. If you provide a complete key, the entity will be updated with the data specified.
By default, all properties are indexed. To prevent a property from being included in *all* indexes, you must supply an excludeFromIndexes
array. See below for an example.
Parameter
Name | Description |
entities |
Entities
Datastore key object(s).
|
Returns
update(entities)
update(entities: Entities): void;
Maps to , forcing the method to be update
.
Parameter
Name | Description |
entities |
Entities
Datastore key object(s).
|
Returns
upsert(entities)
upsert(entities: Entities): void;
Maps to , forcing the method to be upsert
.
Parameter
Name | Description |
entities |
Entities
Datastore key object(s).
|
Returns