Inheritance
GrpcService
>
Spanner
Package
@google-cloud/spanner!
Constructors
(constructor)(options)
constructor(options?: SpannerOptions);
Constructs a new instance of the Spanner
class
Parameter
Properties
auth
Property Value
Type | Description |
---|
GoogleAuth | |
clients_
clients_: Map<string, {}>;
Property Value
Type | Description |
---|
Map<string, {}> | |
COMMIT_TIMESTAMP
static COMMIT_TIMESTAMP: string;
Placeholder used to auto populate a column with the commit timestamp. This can only be used for timestamp columns that have set the option "(allow_commit_timestamp=true)" in the schema.
{string}
Property Value
instances_
instances_: Map<string, Instance>;
Property Value
Type | Description |
---|
Map<string, Instance> | |
options
options: GoogleAuthOptions;
Property Value
Type | Description |
---|
GoogleAuthOptions | |
projectFormattedName_: string;
Property Value
projectIdReplaced_
projectIdReplaced_: boolean;
Property Value
resourceHeader_: {
[k: string]: string;
};
Property Value
Type | Description |
---|
{
[k: string]: string;
} | |
Methods
close()
Closes this Spanner client and cleans up all resources used by it.
Returns
createInstance(name, config)
createInstance(name: string, config: CreateInstanceRequest): Promise<CreateInstanceResponse>;
Parameters
Returns
Type | Description |
---|
Promise<CreateInstanceResponse> | |
createInstance(name, config, callback)
createInstance(name: string, config: CreateInstanceRequest, callback: CreateInstanceCallback): void;
Parameters
Returns
date(dateString)
static date(dateString?: string): any;
Parameter
Type | Name | Description |
---|
string | dateString |
|
Returns
date(year, month, date)
static date(year: number, month: number, date: number): any;
Parameters
Type | Name | Description |
---|
number | year |
|
number | month |
|
number | date |
|
Returns
float(value)
static float(value: any): Float;
Helper function to get a Cloud Spanner Float64 object.
Parameter
Type | Name | Description |
---|
any | value |
The float as a number or string.
|
Returns
Type | Description |
---|
Float | {Float}
|
getInstanceConfig(name)
getInstanceConfig(name: string): Promise<GetInstanceConfigResponse>;
Parameter
Type | Name | Description |
---|
string | name |
|
Returns
Type | Description |
---|
Promise<GetInstanceConfigResponse> | |
getInstanceConfig(name, options)
getInstanceConfig(name: string, options: GetInstanceConfigOptions): Promise<GetInstanceConfigResponse>;
Parameters
Returns
Type | Description |
---|
Promise<GetInstanceConfigResponse> | |
getInstanceConfig(name, callback)
getInstanceConfig(name: string, callback: GetInstanceConfigCallback): void;
Parameters
Type | Name | Description |
---|
string | name |
|
GetInstanceConfigCallback | callback |
|
Returns
getInstanceConfig(name, options, callback)
getInstanceConfig(name: string, options: GetInstanceConfigOptions, callback: GetInstanceConfigCallback): void;
Parameters
Returns
getInstanceConfigs(query)
getInstanceConfigs(query?: GetInstanceConfigsOptions): Promise<GetInstanceConfigsResponse>;
Parameter
Type | Name | Description |
---|
GetInstanceConfigsOptions | query |
|
Returns
Type | Description |
---|
Promise<GetInstanceConfigsResponse> | |
getInstanceConfigs(callback)
getInstanceConfigs(callback: GetInstanceConfigsCallback): void;
Parameter
Type | Name | Description |
---|
GetInstanceConfigsCallback | callback |
|
Returns
getInstanceConfigs(query, callback)
getInstanceConfigs(query: GetInstanceConfigsOptions, callback: GetInstanceConfigsCallback): void;
Parameters
Type | Name | Description |
---|
GetInstanceConfigsOptions | query |
|
GetInstanceConfigsCallback | callback |
|
Returns
getInstanceConfigsStream(options)
getInstanceConfigsStream(options?: GetInstanceConfigsOptions): NodeJS.ReadableStream;
Get a list of instance configs as a readable object stream.
Wrapper around .
[ListInstanceConfigs API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs)
Spanner#getInstanceConfigsStream
Parameter
Type | Name | Description |
---|
GetInstanceConfigsOptions | options |
Query object for listing instance configs.
|
Returns
Type | Description |
---|
NodeJS.ReadableStream | {ReadableStream} A readable stream that emits instance configs.
|
getInstances(options)
getInstances(options?: GetInstancesOptions): Promise<GetInstancesResponse>;
Parameter
Type | Name | Description |
---|
GetInstancesOptions | options |
|
Returns
Type | Description |
---|
Promise<GetInstancesResponse> | |
getInstances(callback)
getInstances(callback: GetInstancesCallback): void;
Parameter
Type | Name | Description |
---|
GetInstancesCallback | callback |
|
Returns
getInstances(query, callback)
getInstances(query: GetInstancesOptions, callback: GetInstancesCallback): void;
Parameters
Type | Name | Description |
---|
GetInstancesOptions | query |
|
GetInstancesCallback | callback |
|
Returns
getInstancesStream(options)
getInstancesStream(options?: GetInstancesOptions): NodeJS.ReadableStream;
Get a list of Instance objects as a readable object stream.
Wrapper around .
[ListInstances API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.ListInstances)
Spanner#getInstancesStream
Parameter
Type | Name | Description |
---|
GetInstancesOptions | options |
Query object for listing instances.
|
Returns
Type | Description |
---|
NodeJS.ReadableStream | {ReadableStream} A readable stream that emits Instance instances.
|
getSpannerEmulatorHost()
static getSpannerEmulatorHost(): {
endpoint: string;
port?: number;
} | undefined;
Gets the configured Spanner emulator host from an environment variable.
Returns
Type | Description |
---|
{
endpoint: string;
port?: number;
} | undefined | |
instance(name)
instance(name: string): Instance;
Get a reference to an Instance object.
Parameter
Type | Name | Description |
---|
string | name |
The name of the instance.
|
Returns
Type | Description |
---|
Instance | {Instance} An Instance object.
|
int(value)
static int(value: any): Int;
Helper function to get a Cloud Spanner Int64 object.
Parameter
Type | Name | Description |
---|
any | value |
The int as a number or string.
|
Returns
numeric(value)
static numeric(value: any): Numeric;
Helper function to get a Cloud Spanner Numeric object.
Parameter
Type | Name | Description |
---|
any | value |
The numeric value as a string.
|
Returns
Type | Description |
---|
Numeric | {Numeric}
|
prepareGapicRequest_(config, callback)
prepareGapicRequest_(config: any, callback: any): void;
Prepare a gapic request. This will cache the GAX client and replace {{projectId}} placeholders, if necessary.
Parameters
Type | Name | Description |
---|
any | config |
Request config
|
any | callback |
Callback function
|
Returns
request(config, callback)
request(config: any, callback?: any): any;
Funnel all API requests through this method to be sure we have a project ID.
Parameters
Type | Name | Description |
---|
any | config |
Configuration object.
|
any | callback |
Callback function.
|
Returns
Type | Description |
---|
any | {Promise}
|
requestStream(config)
requestStream(config: any): any;
Funnel all streaming API requests through this method to be sure we have a project ID.
Parameter
Type | Name | Description |
---|
any | config |
Configuration object.
|
Returns
Type | Description |
---|
any | {Stream}
|
struct(value)
static struct(value?: any): Struct;
Helper function to get a Cloud Spanner Struct object.
Parameter
Type | Name | Description |
---|
any | value |
The struct as a JSON object.
|
Returns
Type | Description |
---|
Struct | {Struct}
|
timestamp(value)
static timestamp(value?: string | number | p.ITimestamp | PreciseDate): PreciseDate;
Helper function to get a Cloud Spanner Timestamp object.
String timestamps should have a canonical format of YYYY-[M]M-[D]D[( |T)[H]H:[M]M:[S]S[.DDDDDDDDD]]Z
**Timestamp values must be expressed in Zulu time and cannot include a UTC offset.**
https://cloud.google.com/spanner/docs/data-types#timestamp-type
Parameter
Type | Name | Description |
---|
string | number | common.ITimestamp | PreciseDate | value |
|
Returns
Type | Description |
---|
PreciseDate | {external:PreciseDate}
|