Class Transaction

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
Name Description
datastore Datastore
options TransactionOptions

Properties

modifiedEntities_

  modifiedEntities_ 
 : 
  
 ModifiedEntities 
 ; 
 
Property Value
Type Description
ModifiedEntities

namespace

  namespace 
 ?: 
  
 string 
 ; 
 
Property Value
Type Description
string

readOnly

  readOnly 
 : 
  
 boolean 
 ; 
 
Property Value
Type Description
boolean

request

  request 
 : 
  
 Function 
 ; 
 
Property Value
Type Description
Function

skipCommit

  skipCommit 
 ?: 
  
 boolean 
 ; 
 
Property Value
Type Description
boolean

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
Type Description
void

commit(gaxOptions, callback)

  commit 
 ( 
 gaxOptions 
 : 
  
 CallOptions 
 , 
  
 callback 
 : 
  
 CommitCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Name Description
gaxOptions CallOptions
callback CommitCallback
Returns
Type Description
void

createQuery(kind)

  createQuery 
 ( 
 kind 
 ?: 
  
 string 
 ) 
 : 
  
 Query 
 ; 
 
Parameter
Name Description
kind string
Returns
Type Description
Query

createQuery(kind)

  createQuery 
 ( 
 kind 
 ?: 
  
 string 
 []) 
 : 
  
 Query 
 ; 
 
Parameter
Name Description
kind string[]
Returns
Type Description
Query

createQuery(namespace, kind)

  createQuery 
 ( 
 namespace 
 : 
  
 string 
 , 
  
 kind 
 : 
  
 string 
 ) 
 : 
  
 Query 
 ; 
 
Parameters
Name Description
namespace string
kind string
Returns
Type Description
Query

createQuery(namespace, kind)

  createQuery 
 ( 
 namespace 
 : 
  
 string 
 , 
  
 kind 
 : 
  
 string 
 []) 
 : 
  
 Query 
 ; 
 
Parameters
Name Description
namespace string
kind string[]
Returns
Type Description
Query

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
Type Description
any

insert(entities)

  insert 
 ( 
 entities 
 : 
  
 Entities 
 ) 
 : 
  
 void 
 ; 
 

Maps to , forcing the method to be insert .

Parameter
Name Description
entities Entities

Datastore key object(s).

Returns
Type Description
void

rollback(callback)

  rollback 
 ( 
 callback 
 : 
  
 RollbackCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameter
Name Description
callback RollbackCallback
Returns
Type Description
void

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
Type Description
void

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
Type Description
void

run(options, callback)

  run 
 ( 
 options 
 : 
  
 RunOptions 
 , 
  
 callback 
 : 
  
 RunCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Name Description
options RunOptions
callback RunCallback
Returns
Type Description
void

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
Type Description
void

update(entities)

  update 
 ( 
 entities 
 : 
  
 Entities 
 ) 
 : 
  
 void 
 ; 
 

Maps to , forcing the method to be update .

Parameter
Name Description
entities Entities

Datastore key object(s).

Returns
Type Description
void

upsert(entities)

  upsert 
 ( 
 entities 
 : 
  
 Entities 
 ) 
 : 
  
 void 
 ; 
 

Maps to , forcing the method to be upsert .

Parameter
Name Description
entities Entities

Datastore key object(s).

Returns
Type Description
void
Create a Mobile Website
View Site in Mobile | Classic
Share by: