This transaction type provides guaranteed consistency across several reads, but does not allow writes. Snapshot read-only transactions can be configured to read at timestamps in the past.
When finished with the Snapshot, call to release the underlying Session . Failure to do so can result in a Session leak.
**This object is created and returned from .**
[Timestamp Bounds API Documentation]( https://cloud.google.com/spanner/docs/timestamp-bounds )
Inheritance
EventEmitter > SnapshotPackage
@google-cloud/spanner!Constructors
(constructor)(session, options, queryOptions)
constructor
(
session
:
Session
,
options
?:
TimestampBounds
,
queryOptions
?:
IQueryOptions
);
Constructs a new instance of the Snapshot
class
Type | Name | Description |
---|---|---|
session | The parent Session object. |
|
TimestampBounds
|
options | Snapshot timestamp bounds. |
spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions
|
queryOptions | Default query options to use when none are specified for a query. |
Properties
_options
protected
_options
:
spannerClient
.
spanner
.
v1
.
ITransactionOptions
;
Type | Description |
---|---|
spannerClient.spanner.v1.ITransactionOptions |
_seqno
protected
_seqno
:
number
;
Type | Description |
---|---|
number |
ended
ended
:
boolean
;
Type | Description |
---|---|
boolean |
id
id
?:
Uint8Array
|
string
;
Type | Description |
---|---|
Uint8Array | string |
metadata
metadata
?:
spannerClient
.
spanner
.
v1
.
ITransaction
;
Type | Description |
---|---|
spannerClient.spanner.v1.ITransaction |
queryOptions
queryOptions
?:
IQueryOptions
;
Type | Description |
---|---|
spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions |
readTimestamp
readTimestamp
?:
PreciseDate
;
Type | Description |
---|---|
PreciseDate |
readTimestampProto
readTimestampProto
?:
spannerClient
.
protobuf
.
ITimestamp
;
Type | Description |
---|---|
spannerClient.protobuf.ITimestamp |
request
request
:
(
config
:
{},
callback
:
Function
)
=
>
void
;
Type | Description |
---|---|
(config: {}, callback: Function ) => void |
requestOptions
requestOptions
?:
Pick<IRequestOptions
,
'transactionTag'
> ;
Type | Description |
---|---|
Pick < google.spanner.v1.IRequestOptions , 'transactionTag'> |
requestStream
requestStream
:
(
config
:
{})
=
>
Readable
;
Type | Description |
---|---|
(config: {}) => internal.Readable |
resourceHeader_
resourceHeader_
:
{
[
k
:
string
]
:
string
;
};
Type | Description |
---|---|
{ [k: string]: string; } |
session
session
:
Session
;
Type | Description |
---|---|
Session |
Methods
begin(gaxOptions)
begin
(
gaxOptions
?:
CallOptions
)
:
Promise<BeginResponse>
;
Type | Name | Description |
---|---|---|
CallOptions
|
gaxOptions |
Type | Description |
---|---|
Promise < BeginResponse > |
begin(callback)
begin
(
callback
:
BeginTransactionCallback
)
:
void
;
Type | Name | Description |
---|---|---|
BeginTransactionCallback
|
callback |
Type | Description |
---|---|
void |
begin(gaxOptions, callback)
begin
(
gaxOptions
:
CallOptions
,
callback
:
BeginTransactionCallback
)
:
void
;
Type | Name | Description |
---|---|---|
CallOptions
|
gaxOptions | |
BeginTransactionCallback
|
callback |
Type | Description |
---|---|
void |
configureTagOptions(singleUse, transactionTag, requestOptions)
configureTagOptions
(
singleUse
?:
boolean
,
transactionTag
?:
string
,
requestOptions
?:
{})
:
IRequestOptions
|
null
;
Type | Name | Description |
---|---|---|
boolean
|
singleUse | |
string
|
transactionTag | |
{}
|
requestOptions |
Type | Description |
---|---|
google.spanner.v1.IRequestOptions | null |
createReadStream(table, request)
createReadStream
(
table
:
string
,
request
?:
ReadRequest
)
:
PartialResultStream
;
Create a readable object stream to receive rows from the database using key lookups and scans.
Wrapper around .
[StreamingRead API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.StreamingRead) [ReadRequest API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ReadRequest)
PartialResultStream#response PartialResultStream#stats
Type | Name | Description |
---|---|---|
string
|
table | The table to read from. |
ReadRequest
|
request |
Type | Description |
---|---|
PartialResultStream | {ReadableStream} A readable stream that emits rows. |
encodeKeySet(request)
static
encodeKeySet
(
request
:
ReadRequest
)
:
spannerClient
.
spanner
.
v1
.
IKeySet
;
Transforms convenience options keys
and ranges
into a KeySet object.
Type | Name | Description |
---|---|---|
ReadRequest
|
request | The read request. |
Type | Description |
---|---|
spannerClient.spanner.v1.IKeySet | {object} |
encodeParams(request)
static
encodeParams
(
request
:
ExecuteSqlRequest
)
:
{
params
:
p
.
IStruct
;
paramTypes
:
{
[
field
:
string
]
:
spannerClient
.
spanner
.
v1
.
Type
;
};
};
Encodes convenience options param
and types
into the proto formatted.
Type | Name | Description |
---|---|---|
ExecuteSqlRequest
|
request | The SQL request. |
Type | Description |
---|---|
{ params: common.IStruct ; paramTypes: { [field: string]: google.spanner.v1.Type ; }; } | {object} |
encodeTimestampBounds(options)
static
encodeTimestampBounds
(
options
:
TimestampBounds
)
:
spannerClient
.
spanner
.
v1
.
TransactionOptions
.
IReadOnly
;
Formats timestamp options into proto format.
Type | Name | Description |
---|---|---|
TimestampBounds
|
options | The user supplied options. |
Type | Description |
---|---|
spannerClient.spanner.v1.TransactionOptions.IReadOnly | {object} |
end()
end
()
:
void
;
Let the client know you're done with a particular transaction. This should mainly be called for Snapshot objects, however in certain cases you may want to call them for Transaction objects as well.
Type | Description |
---|---|
void |
read(table, request)
read
(
table
:
string
,
request
:
ReadRequest
)
:
Promise<ReadResponse>
;
Type | Name | Description |
---|---|---|
string
|
table | |
ReadRequest
|
request |
Type | Description |
---|---|
Promise < ReadResponse > |
read(table, callback)
read
(
table
:
string
,
callback
:
ReadCallback
)
:
void
;
Type | Name | Description |
---|---|---|
string
|
table | |
ReadCallback
|
callback |
Type | Description |
---|---|
void |
read(table, request, callback)
read
(
table
:
string
,
request
:
ReadRequest
,
callback
:
ReadCallback
)
:
void
;
Type | Name | Description |
---|---|---|
string
|
table | |
ReadRequest
|
request | |
ReadCallback
|
callback |
Type | Description |
---|---|
void |
run(query)
run
(
query
:
string
|
ExecuteSqlRequest
)
:
Promise<RunResponse>
;
Type | Name | Description |
---|---|---|
string | ExecuteSqlRequest
|
query |
Type | Description |
---|---|
Promise < RunResponse > |
run(query, callback)
run
(
query
:
string
|
ExecuteSqlRequest
,
callback
:
RunCallback
)
:
void
;
Type | Name | Description |
---|---|---|
string | ExecuteSqlRequest
|
query | |
RunCallback
|
callback |
Type | Description |
---|---|
void |
runStream(query)
runStream
(
query
:
string
|
ExecuteSqlRequest
)
:
PartialResultStream
;
Create a readable object stream to receive resulting rows from a SQL statement.
Wrapper around .
[ExecuteStreamingSql API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.ExecuteStreamingSql) [ExecuteSqlRequest API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
PartialResultStream#response PartialResultStream#stats
Type | Name | Description |
---|---|---|
string | ExecuteSqlRequest
|
query | A SQL query or object. |
Type | Description |
---|---|
PartialResultStream | {ReadableStream} |