Class Spanner

[Cloud Spanner]( https://cloud.google.com/spanner ) is a highly scalable, transactional, managed, NewSQL database service. Cloud Spanner solves the need for a horizontally-scaling database with consistent global transaction and SQL semantics. With Cloud Spanner you don't need to choose between consistency and horizontal scaling — you get both.

[Cloud Spanner Documentation]( https://cloud.google.com/spanner/docs ) [Cloud Spanner Concepts]( https://cloud.google.com/spanner/docs/concepts )

Inheritance

GrpcService > Spanner

Package

@google-cloud/spanner!

Constructors

(constructor)(options)

  constructor 
 ( 
 options 
 ?: 
  
 SpannerOptions 
 ); 
 

Constructs a new instance of the Spanner class

Parameter
Type Name Description
options

Properties

auth

  auth 
 : 
  
 GoogleAuth 
 ; 
 
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
Type Description
string

instances_

  instances_ 
 : 
  
 Map<string 
 , 
  
 Instance 
> ; 
 
Property Value
Type Description
Map <string, Instance >

options

  options 
 : 
  
 GoogleAuthOptions 
 ; 
 
Property Value
Type Description
GoogleAuthOptions

projectFormattedName_

  projectFormattedName_ 
 : 
  
 string 
 ; 
 
Property Value
Type Description
string

projectIdReplaced_

  projectIdReplaced_ 
 : 
  
 boolean 
 ; 
 
Property Value
Type Description
boolean

resourceHeader_

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

Methods

close()

  close 
 () 
 : 
  
 void 
 ; 
 

Closes this Spanner client and cleans up all resources used by it.

Returns
Type Description
void

createInstance(name, config)

  createInstance 
 ( 
 name 
 : 
  
 string 
 , 
  
 config 
 : 
  
 CreateInstanceRequest 
 ) 
 : 
  
 Promise<CreateInstanceResponse> 
 ; 
 
Parameters
Type Name Description
string
name
config
Returns
Type Description
Promise < CreateInstanceResponse >

createInstance(name, config, callback)

  createInstance 
 ( 
 name 
 : 
  
 string 
 , 
  
 config 
 : 
  
 CreateInstanceRequest 
 , 
  
 callback 
 : 
  
 CreateInstanceCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Type Name Description
string
name
config
CreateInstanceCallback
callback
Returns
Type Description
void

date(dateString)

  static 
  
 date 
 ( 
 dateString 
 ?: 
  
 string 
 ) 
 : 
  
 any 
 ; 
 
Parameter
Type Name Description
string
dateString
Returns
Type Description
any

date(year, month, date)

  static 
  
 date 
 ( 
 year 
 : 
  
 number 
 , 
  
 month 
 : 
  
 number 
 , 
  
 date 
 : 
  
 number 
 ) 
 : 
  
 any 
 ; 
 
Parameters
Type Name Description
number
year
number
month
number
date
Returns
Type Description
any

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}

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

getInstanceConfigs(query, callback)

  getInstanceConfigs 
 ( 
 query 
 : 
  
 GetInstanceConfigsOptions 
 , 
  
 callback 
 : 
  
 GetInstanceConfigsCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Type Name Description
GetInstanceConfigsOptions
query
GetInstanceConfigsCallback
callback
Returns
Type Description
void

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

getInstances(query, callback)

  getInstances 
 ( 
 query 
 : 
  
 GetInstancesOptions 
 , 
  
 callback 
 : 
  
 GetInstancesCallback 
 ) 
 : 
  
 void 
 ; 
 
Parameters
Type Name Description
GetInstancesOptions
query
GetInstancesCallback
callback
Returns
Type Description
void

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

{Int}

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

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}

Create a Mobile Website
View Site in Mobile | Classic
Share by: