Send feedback
Class Session
Stay organized with collections
Save and categorize content based on your preferences.
Version 5.10.0 keyboard_arrow_down
Create a Session object to interact with a Cloud Spanner session.
**It is unlikely you will need to interact with sessions directly. By default, sessions are created and utilized for maximum performance automatically.**
Inheritance
common .GrpcServiceObject
>
Session
Package
@google-cloud/spanner!
Constructors
(constructor)(database, name)
constructor ( database : Database , name ?: string );
Constructs a new instance of the Session
class
Parameters
Type
Name
Description
Database
database
string
name
Properties
Property Value
id
Property Value
lastError
lastError ?: grpc . ServiceError ;
Property Value
Type
Description
grpc.ServiceError
lastUsed
Property Value
resourceHeader_ : {
[ k : string ] : string ;
};
Property Value
Type
Description
{
[k: string]: string;
}
txn
Property Value
type
Property Value
Methods
delete(gaxOptions)
delete ( gaxOptions ?: CallOptions ) : Promise<DeleteSessionResponse> ;
Parameter
Type
Name
Description
CallOptions
gaxOptions
Returns
Type
Description
Promise <DeleteSessionResponse >
delete(callback)
delete ( callback : DeleteSessionCallback ) : void ;
Parameter
Type
Name
Description
DeleteSessionCallback
callback
Returns
delete(gaxOptions, callback)
delete ( gaxOptions : CallOptions , callback : DeleteSessionCallback ) : void ;
Parameters
Type
Name
Description
CallOptions
gaxOptions
DeleteSessionCallback
callback
Returns
static formatName_ ( databaseName : string , name : string ) : string ;
Format the session name to include the parent database's name.
Parameters
Type
Name
Description
string
databaseName
The parent database's name.
string
name
The instance name.
Returns
Type
Description
string
{string}
getMetadata ( gaxOptions ?: CallOptions ) : Promise<GetSessionMetadataResponse> ;
Parameter
Type
Name
Description
CallOptions
gaxOptions
Returns
Type
Description
Promise <GetSessionMetadataResponse >
getMetadata ( callback : GetSessionMetadataCallback ) : void ;
Parameter
Type
Name
Description
GetSessionMetadataCallback
callback
Returns
getMetadata ( gaxOptions : CallOptions , callback : GetSessionMetadataCallback ) : void ;
Parameters
Type
Name
Description
CallOptions
gaxOptions
GetSessionMetadataCallback
callback
Returns
keepAlive(gaxOptions)
keepAlive ( gaxOptions ?: CallOptions ) : Promise<KeepAliveResponse> ;
Parameter
Type
Name
Description
CallOptions
gaxOptions
Returns
Type
Description
Promise <KeepAliveResponse >
keepAlive(callback)
keepAlive ( callback : KeepAliveCallback ) : void ;
Parameter
Type
Name
Description
KeepAliveCallback
callback
Returns
keepAlive(gaxOptions, callback)
keepAlive ( gaxOptions : CallOptions , callback : KeepAliveCallback ) : void ;
Parameters
Type
Name
Description
CallOptions
gaxOptions
KeepAliveCallback
callback
Returns
partitionedDml()
partitionedDml () : PartitionedDml ;
Create a PartitionedDml transaction.
Returns
snapshot(options, queryOptions)
snapshot ( options ?: TimestampBounds , queryOptions ?: google . spanner . v1 . ExecuteSqlRequest . IQueryOptions ) : Snapshot ;
Create a Snapshot transaction.
Parameters
Type
Name
Description
TimestampBounds
options
The timestamp bounds.
IQueryOptions
queryOptions
The default query options to use.
Returns
transaction(queryOptions)
transaction ( queryOptions ?: google . spanner . v1 . ExecuteSqlRequest . IQueryOptions ) : Transaction ;
Create a read write Transaction.
Parameter
Type
Name
Description
IQueryOptions
queryOptions
The default query options to use. {Transaction}
Returns
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-02 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-02 UTC."],[],[]]