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
Type Name Description
Database database
string name

Properties

formattedName_

formattedName_?: string;
Property Value
Type Description
string

id

id: string;
Property Value
Type Description
string

lastError

lastError?: grpc.ServiceError;
Property Value
Type Description
grpc.ServiceError

lastUsed

lastUsed?: number;
Property Value
Type Description
number

resourceHeader_

resourceHeader_: {
        [k: string]: string;
    };
Property Value
Type Description
{ [k: string]: string; }

txn

txn?: Transaction;
Property Value
Type Description
Transaction

type

type?: types;
Property Value
Type Description
types

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

delete(gaxOptions, callback)

delete(gaxOptions: CallOptions, callback: DeleteSessionCallback): void;
Parameters
Type Name Description
CallOptions gaxOptions
DeleteSessionCallback callback
Returns
Type Description
void

formatName_(databaseName, name)

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)

getMetadata(gaxOptions?: CallOptions): Promise<GetSessionMetadataResponse>;
Parameter
Type Name Description
CallOptions gaxOptions
Returns
Type Description
Promise<GetSessionMetadataResponse>

getMetadata(callback)

getMetadata(callback: GetSessionMetadataCallback): void;
Parameter
Type Name Description
GetSessionMetadataCallback callback
Returns
Type Description
void

getMetadata(gaxOptions, callback)

getMetadata(gaxOptions: CallOptions, callback: GetSessionMetadataCallback): void;
Parameters
Type Name Description
CallOptions gaxOptions
GetSessionMetadataCallback callback
Returns
Type Description
void

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

keepAlive(gaxOptions, callback)

keepAlive(gaxOptions: CallOptions, callback: KeepAliveCallback): void;
Parameters
Type Name Description
CallOptions gaxOptions
KeepAliveCallback callback
Returns
Type Description
void

partitionedDml()

partitionedDml(): PartitionedDml;

Create a PartitionedDml transaction.

Returns
Type Description
PartitionedDml

{PartitionedDml}

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

{Snapshot}

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