Send feedback
Class Snapshot
Stay organized with collections
Save and categorize content based on your preferences.
Version 5.14.0 keyboard_arrow_down
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
>
Snapshot
Package
@google-cloud/spanner!
Constructors
(constructor)(session, options, queryOptions)
constructor ( session : Session , options ? : TimestampBounds , queryOptions ? : IQueryOptions );
Constructs a new instance of the Snapshot
class
Parameters
Type Name Description Session 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 ;
Property Value
Type Description spannerClient.spanner.v1.ITransactionOptions
_seqno
protected _seqno : number ;
Property Value
ended
Property Value
id
id?: Uint8Array | string;
Property Value
Type Description Uint8Array | string
metadata?: spannerClient.spanner.v1.ITransaction;
Property Value
Type Description spannerClient.spanner.v1.ITransaction
queryOptions
queryOptions?: IQueryOptions;
Property Value
Type Description spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions
readTimestamp
readTimestamp?: PreciseDate;
Property Value
Type Description PreciseDate
readTimestampProto
readTimestampProto?: spannerClient.protobuf.ITimestamp;
Property Value
Type Description spannerClient.protobuf.ITimestamp
request
request : ( config : {} , callback : Function ) = > void ;
Property Value
Type Description (config: {}, callback: Function ) => void
requestOptions
requestOptions?: Pick<IRequestOptions, 'transactionTag'>;
Property Value
Type Description Pick <google.spanner.v1.IRequestOptions , 'transactionTag'>
requestStream
requestStream : ( config : {} ) = > Readable ;
Property Value
Type Description (config: {}) => internal.Readable
resourceHeader_ : {
[ k : string ] : string ;
} ;
Property Value
Type Description {
[k: string]: string;
}
session
Property Value
Methods
begin(gaxOptions)
begin(gaxOptions?: CallOptions): Promise<BeginResponse>;
Parameter
Type Name Description CallOptions gaxOptions
Returns
Type Description Promise <BeginResponse >
begin(callback)
begin ( callback : BeginTransactionCallback ): void ;
Parameter
Type Name Description BeginTransactionCallback callback
Returns
begin(gaxOptions, callback)
begin ( gaxOptions : CallOptions , callback : BeginTransactionCallback ): void ;
Parameters
Type Name Description CallOptions gaxOptions
BeginTransactionCallback callback
Returns
configureTagOptions(singleUse?: boolean, transactionTag?: string, requestOptions?: {}): IRequestOptions | null;
Parameters
Type Name Description boolean singleUse
string transactionTag
{} requestOptions
Returns
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
Parameters
Type Name Description string table
The table to read from.
ReadRequest request
Returns
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.
Parameter
Type Name Description ReadRequest request
The read request.
Returns
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.
Parameter
Type Name Description ExecuteSqlRequest request
The SQL request.
Returns
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.
Parameter
Type Name Description TimestampBounds options
The user supplied options.
Returns
Type Description spannerClient.spanner.v1.TransactionOptions.IReadOnly {object}
end()
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.
Returns
read(table, request)
read ( table : string , request : ReadRequest ): Promise<ReadResponse> ;
Parameters
Type Name Description string table
ReadRequest request
Returns
Type Description Promise <ReadResponse >
read(table, callback)
read ( table : string , callback : ReadCallback ): void ;
Parameters
Type Name Description string table
ReadCallback callback
Returns
read(table, request, callback)
read ( table : string , request : ReadRequest , callback : ReadCallback ): void ;
Parameters
Type Name Description string table
ReadRequest request
ReadCallback callback
Returns
run(query)
run ( query : string | ExecuteSqlRequest ): Promise<RunResponse> ;
Parameter
Type Name Description string | ExecuteSqlRequest query
Returns
Type Description Promise <RunResponse >
run(query, callback)
run ( query : string | ExecuteSqlRequest , callback : RunCallback ): void ;
Parameters
Type Name Description string | ExecuteSqlRequest query
RunCallback callback
Returns
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
Parameter
Type Name Description string | ExecuteSqlRequest query
A SQL query or object.
Returns
Type Description PartialResultStream {ReadableStream}
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 2024-09-10 UTC.
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2024-09-10 UTC."}