[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 > SpannerPackage
@google-cloud/spanner!Constructors
(constructor)(options)
constructor
(
options
?:
SpannerOptions
);
Constructs a new instance of the Spanner
class
Type | Name | Description |
---|---|---|
options |
Properties
auth
auth
:
GoogleAuth
;
Type | Description |
---|---|
GoogleAuth |
clients_
clients_
:
Map<string
,
{}>;
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}
Type | Description |
---|---|
string |
instances_
instances_
:
Map<string
,
Instance
> ;
Type | Description |
---|---|
Map <string, Instance > |
options
options
:
GoogleAuthOptions
;
Type | Description |
---|---|
GoogleAuthOptions |
projectFormattedName_
projectFormattedName_
:
string
;
Type | Description |
---|---|
string |
resourceHeader_
resourceHeader_
:
{
[
k
:
string
]
:
string
;
};
Type | Description |
---|---|
{ [k: string]: string; } |
Methods
createInstance(name, config)
createInstance
(
name
:
string
,
config
:
CreateInstanceRequest
)
:
Promise<CreateInstanceResponse>
;
Type | Name | Description |
---|---|---|
string
|
name | |
config |
Type | Description |
---|---|
Promise < CreateInstanceResponse > |
createInstance(name, config, callback)
createInstance
(
name
:
string
,
config
:
CreateInstanceRequest
,
callback
:
CreateInstanceCallback
)
:
void
;
Type | Name | Description |
---|---|---|
string
|
name | |
config | ||
CreateInstanceCallback
|
callback |
Type | Description |
---|---|
void |
date(dateString)
static
date
(
dateString
?:
string
)
:
any
;
Type | Name | Description |
---|---|---|
string
|
dateString |
Type | Description |
---|---|
any |
date(year, month, date)
static
date
(
year
:
number
,
month
:
number
,
date
:
number
)
:
any
;
Type | Name | Description |
---|---|---|
number
|
year | |
number
|
month | |
number
|
date |
Type | Description |
---|---|
any |
float(value)
static
float
(
value
:
any
)
:
Float
;
Helper function to get a Cloud Spanner Float64 object.
Type | Name | Description |
---|---|---|
any
|
value | The float as a number or string. |
Type | Description |
---|---|
Float | {Float} |
getInstanceConfigs(query)
getInstanceConfigs
(
query
?:
GetInstanceConfigsOptions
)
:
Promise<GetInstanceConfigsResponse>
;
Type | Name | Description |
---|---|---|
GetInstanceConfigsOptions
|
query |
Type | Description |
---|---|
Promise < GetInstanceConfigsResponse > |
getInstanceConfigs(callback)
getInstanceConfigs
(
callback
:
GetInstanceConfigsCallback
)
:
void
;
Type | Name | Description |
---|---|---|
GetInstanceConfigsCallback
|
callback |
Type | Description |
---|---|
void |
getInstanceConfigs(query, callback)
getInstanceConfigs
(
query
:
GetInstanceConfigsOptions
,
callback
:
GetInstanceConfigsCallback
)
:
void
;
Type | Name | Description |
---|---|---|
GetInstanceConfigsOptions
|
query | |
GetInstanceConfigsCallback
|
callback |
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
Type | Name | Description |
---|---|---|
GetInstanceConfigsOptions
|
options | Query object for listing instance configs. |
Type | Description |
---|---|
NodeJS.ReadableStream | {ReadableStream} A readable stream that emits instance configs. |
getInstances(options)
getInstances
(
options
?:
GetInstancesOptions
)
:
Promise<GetInstancesResponse>
;
Type | Name | Description |
---|---|---|
GetInstancesOptions
|
options |
Type | Description |
---|---|
Promise < GetInstancesResponse > |
getInstances(callback)
getInstances
(
callback
:
GetInstancesCallback
)
:
void
;
Type | Name | Description |
---|---|---|
GetInstancesCallback
|
callback |
Type | Description |
---|---|
void |
getInstances(query, callback)
getInstances
(
query
:
GetInstancesOptions
,
callback
:
GetInstancesCallback
)
:
void
;
Type | Name | Description |
---|---|---|
GetInstancesOptions
|
query | |
GetInstancesCallback
|
callback |
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
Type | Name | Description |
---|---|---|
GetInstancesOptions
|
options | Query object for listing instances. |
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.
Type | Description |
---|---|
{ endpoint: string; port?: number; } | undefined |
instance(name)
instance
(
name
:
string
)
:
Instance
;
Get a reference to an Instance object.
Type | Name | Description |
---|---|---|
string
|
name | The name of the instance. |
Type | Description |
---|---|
Instance | {Instance} An Instance object. |
int(value)
static
int
(
value
:
any
)
:
Int
;
Helper function to get a Cloud Spanner Int64 object.
Type | Name | Description |
---|---|---|
any
|
value | The int as a number or string. |
Type | Description |
---|---|
Int | {Int} |
numeric(value)
static
numeric
(
value
:
any
)
:
Numeric
;
Helper function to get a Cloud Spanner Numeric object.
Type | Name | Description |
---|---|---|
any
|
value | The numeric value as a string. |
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.
Type | Name | Description |
---|---|---|
any
|
config | Request config |
any
|
callback | Callback function |
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.
Type | Name | Description |
---|---|---|
any
|
config | Configuration object. |
any
|
callback | Callback function. |
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.
Type | Name | Description |
---|---|---|
any
|
config | Configuration object. |
Type | Description |
---|---|
any | {Stream} |
struct(value)
static
struct
(
value
?:
any
)
:
Struct
;
Helper function to get a Cloud Spanner Struct object.
Type | Name | Description |
---|---|---|
any
|
value | The struct as a JSON object. |
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
Type | Name | Description |
---|---|---|
string | number | common.ITimestamp
| PreciseDate
|
value |
Type | Description |
---|---|
PreciseDate | {external:PreciseDate} |