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 > SessionPackage
@google-cloud/spanner!Constructors
(constructor)(database, name)
constructor
(
database
:
Database
,
name
?:
string
);
Constructs a new instance of the Session
class
| Type | Name | Description |
|---|---|---|
|
Database
|
database | |
|
string
|
name |
Properties
formattedName_
formattedName_
?:
string
;
| Type | Description |
|---|---|
| string |
id
id
:
string
;
| Type | Description |
|---|---|
| string |
lastError
lastError
?:
grpc
.
ServiceError
;
| Type | Description |
|---|---|
| grpc. ServiceError |
lastUsed
lastUsed
?:
number
;
| Type | Description |
|---|---|
| number |
resourceHeader_
resourceHeader_
:
{
[
k
:
string
]
:
string
;
};
| Type | Description |
|---|---|
| { [k: string]: string; } |
txn
txn
?:
Transaction
;
| Type | Description |
|---|---|
| Transaction |
type
type
?:
types
;
| Type | Description |
|---|---|
| types |
Methods
delete(gaxOptions)
delete
(
gaxOptions
?:
CallOptions
)
:
Promise<DeleteSessionResponse>
;
| Type | Name | Description |
|---|---|---|
|
CallOptions
|
gaxOptions |
| Type | Description |
|---|---|
| Promise < DeleteSessionResponse > |
delete(callback)
delete
(
callback
:
DeleteSessionCallback
)
:
void
;
| Type | Name | Description |
|---|---|---|
|
DeleteSessionCallback
|
callback |
| Type | Description |
|---|---|
| void |
delete(gaxOptions, callback)
delete
(
gaxOptions
:
CallOptions
,
callback
:
DeleteSessionCallback
)
:
void
;
| Type | Name | Description |
|---|---|---|
|
CallOptions
|
gaxOptions | |
|
DeleteSessionCallback
|
callback |
| Type | Description |
|---|---|
| void |
formatName_(databaseName, name)
static
formatName_
(
databaseName
:
string
,
name
:
string
)
:
string
;
Format the session name to include the parent database's name.
| Type | Name | Description |
|---|---|---|
|
string
|
databaseName | The parent database's name. |
|
string
|
name | The instance name. |
| Type | Description |
|---|---|
| string | {string} |
getMetadata(gaxOptions)
getMetadata
(
gaxOptions
?:
CallOptions
)
:
Promise<GetSessionMetadataResponse>
;
| Type | Name | Description |
|---|---|---|
|
CallOptions
|
gaxOptions |
| Type | Description |
|---|---|
| Promise < GetSessionMetadataResponse > |
getMetadata(callback)
getMetadata
(
callback
:
GetSessionMetadataCallback
)
:
void
;
| Type | Name | Description |
|---|---|---|
|
GetSessionMetadataCallback
|
callback |
| Type | Description |
|---|---|
| void |
getMetadata(gaxOptions, callback)
getMetadata
(
gaxOptions
:
CallOptions
,
callback
:
GetSessionMetadataCallback
)
:
void
;
| Type | Name | Description |
|---|---|---|
|
CallOptions
|
gaxOptions | |
|
GetSessionMetadataCallback
|
callback |
| Type | Description |
|---|---|
| void |
keepAlive(gaxOptions)
keepAlive
(
gaxOptions
?:
CallOptions
)
:
Promise<KeepAliveResponse>
;
| Type | Name | Description |
|---|---|---|
|
CallOptions
|
gaxOptions |
| Type | Description |
|---|---|
| Promise < KeepAliveResponse > |
keepAlive(callback)
keepAlive
(
callback
:
KeepAliveCallback
)
:
void
;
| Type | Name | Description |
|---|---|---|
|
KeepAliveCallback
|
callback |
| Type | Description |
|---|---|
| void |
keepAlive(gaxOptions, callback)
keepAlive
(
gaxOptions
:
CallOptions
,
callback
:
KeepAliveCallback
)
:
void
;
| Type | Name | Description |
|---|---|---|
|
CallOptions
|
gaxOptions | |
|
KeepAliveCallback
|
callback |
| Type | Description |
|---|---|
| void |
partitionedDml()
partitionedDml
()
:
PartitionedDml
;
Create a PartitionedDml transaction.
| Type | Description |
|---|---|
| PartitionedDml | {PartitionedDml} |
snapshot(options, queryOptions)
snapshot
(
options
?:
TimestampBounds
,
queryOptions
?:
google
.
spanner
.
v1
.
ExecuteSqlRequest
.
IQueryOptions
)
:
Snapshot
;
Create a Snapshot transaction.
| Type | Name | Description |
|---|---|---|
|
TimestampBounds
|
options | The timestamp bounds. |
|
IQueryOptions
|
queryOptions | The default query options to use. |
| Type | Description |
|---|---|
| Snapshot | {Snapshot} |
transaction(queryOptions, requestOptions)
transaction
(
queryOptions
?:
google
.
spanner
.
v1
.
ExecuteSqlRequest
.
IQueryOptions
,
requestOptions
?:
Pick<IRequestOptions
,
'transactionTag'
> )
:
Transaction
;
Create a read write Transaction.
| Type | Name | Description |
|---|---|---|
|
IQueryOptions
|
queryOptions | The default query options to use. {Transaction} |
|
Pick
< google.spanner.v1.IRequestOptions
, 'transactionTag'>
|
requestOptions |
| Type | Description |
|---|---|
| Transaction |

