Class Session

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
TypeNameDescription
Databasedatabase
stringname

Properties

formattedName_

formattedName_?: string;
Property Value
TypeDescription
string

id

id: string;
Property Value
TypeDescription
string

lastError

lastError?: grpc.ServiceError;
Property Value
TypeDescription
grpc.ServiceError

lastUsed

lastUsed?: number;
Property Value
TypeDescription
number

resourceHeader_

resourceHeader_: {
        [k: string]: string;
    };
Property Value
TypeDescription
{ [k: string]: string; }

txn

txn?: Transaction;
Property Value
TypeDescription
Transaction

type

type?: types;
Property Value
TypeDescription
types

Methods

delete(gaxOptions)

delete(gaxOptions?: CallOptions): Promise<DeleteSessionResponse>;
Parameter
TypeNameDescription
CallOptionsgaxOptions
Returns
TypeDescription
Promise<DeleteSessionResponse>

delete(callback)

delete(callback: DeleteSessionCallback): void;
Parameter
TypeNameDescription
DeleteSessionCallbackcallback
Returns
TypeDescription
void

delete(gaxOptions, callback)

delete(gaxOptions: CallOptions, callback: DeleteSessionCallback): void;
Parameters
TypeNameDescription
CallOptionsgaxOptions
DeleteSessionCallbackcallback
Returns
TypeDescription
void

formatName_(databaseName, name)

static formatName_(databaseName: string, name: string): string;

Format the session name to include the parent database's name.

Parameters
TypeNameDescription
stringdatabaseName

The parent database's name.

stringname

The instance name.

Returns
TypeDescription
string

{string}

getMetadata(gaxOptions)

getMetadata(gaxOptions?: CallOptions): Promise<GetSessionMetadataResponse>;
Parameter
TypeNameDescription
CallOptionsgaxOptions
Returns
TypeDescription
Promise<GetSessionMetadataResponse>

getMetadata(callback)

getMetadata(callback: GetSessionMetadataCallback): void;
Parameter
TypeNameDescription
GetSessionMetadataCallbackcallback
Returns
TypeDescription
void

getMetadata(gaxOptions, callback)

getMetadata(gaxOptions: CallOptions, callback: GetSessionMetadataCallback): void;
Parameters
TypeNameDescription
CallOptionsgaxOptions
GetSessionMetadataCallbackcallback
Returns
TypeDescription
void

keepAlive(gaxOptions)

keepAlive(gaxOptions?: CallOptions): Promise<KeepAliveResponse>;
Parameter
TypeNameDescription
CallOptionsgaxOptions
Returns
TypeDescription
Promise<KeepAliveResponse>

keepAlive(callback)

keepAlive(callback: KeepAliveCallback): void;
Parameter
TypeNameDescription
KeepAliveCallbackcallback
Returns
TypeDescription
void

keepAlive(gaxOptions, callback)

keepAlive(gaxOptions: CallOptions, callback: KeepAliveCallback): void;
Parameters
TypeNameDescription
CallOptionsgaxOptions
KeepAliveCallbackcallback
Returns
TypeDescription
void

partitionedDml()

partitionedDml(): PartitionedDml;

Create a PartitionedDml transaction.

Returns
TypeDescription
PartitionedDml

{PartitionedDml}

snapshot(options, queryOptions)

snapshot(options?: TimestampBounds, queryOptions?: google.spanner.v1.ExecuteSqlRequest.IQueryOptions): Snapshot;

Create a Snapshot transaction.

Parameters
TypeNameDescription
TimestampBoundsoptions

The timestamp bounds.

IQueryOptionsqueryOptions

The default query options to use.

Returns
TypeDescription
Snapshot

{Snapshot}

transaction(queryOptions)

transaction(queryOptions?: google.spanner.v1.ExecuteSqlRequest.IQueryOptions): Transaction;

Create a read write Transaction.

Parameter
TypeNameDescription
IQueryOptionsqueryOptions

The default query options to use. {Transaction}

Returns
TypeDescription
Transaction