Class Instance

The Instance class represents a [Cloud Spanner instance](https://cloud.google.com/spanner/docs/instances).

Create an Instance object to interact with a Cloud Spanner instance.

Inheritance

common.GrpcServiceObject > Instance

Package

@google-cloud/spanner!

Constructors

(constructor)(spanner, name)

constructor(spanner: Spanner, name: string);

Constructs a new instance of the Instance class

Parameters
TypeNameDescription
Spannerspanner
stringname

Properties

databases_

databases_: Map<string, Database>;
Property Value
TypeDescription
Map<string, Database>

formattedName_

formattedName_: string;
Property Value
TypeDescription
string

metadata

metadata?: IInstance;
Property Value
TypeDescription
IInstance

request

request: InstanceRequest;
Property Value
TypeDescription
InstanceRequest

requestStream

requestStream: (config: RequestConfig) => Duplex;
Property Value
TypeDescription
(config: RequestConfig) => internal.Duplex

resourceHeader_

resourceHeader_: {
        [k: string]: string;
    };
Property Value
TypeDescription
{ [k: string]: string; }

Methods

backup(backupId)

backup(backupId: string): Backup;

Get a reference to a Backup object.

Parameter
TypeNameDescription
stringbackupId

The name of the backup. {Backup} A Backup object.

Returns
TypeDescription
Backup

createDatabase(name, options)

createDatabase(name: string, options?: CreateDatabaseOptions): Promise<CreateDatabaseResponse>;
Parameters
TypeNameDescription
stringname
CreateDatabaseOptionsoptions
Returns
TypeDescription
Promise<CreateDatabaseResponse>

createDatabase(name, callback)

createDatabase(name: string, callback: CreateDatabaseCallback): void;
Parameters
TypeNameDescription
stringname
CreateDatabaseCallbackcallback
Returns
TypeDescription
void

createDatabase(name, options, callback)

createDatabase(name: string, options: CreateDatabaseOptions, callback: CreateDatabaseCallback): void;
Parameters
TypeNameDescription
stringname
CreateDatabaseOptionsoptions
CreateDatabaseCallbackcallback
Returns
TypeDescription
void

database(name, poolOptions, queryOptions)

database(name: string, poolOptions?: SessionPoolOptions | SessionPoolConstructor, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions): Database;

Get a reference to a Database object.

Parameters
TypeNameDescription
stringname

The name of the instance.

SessionPoolOptions | SessionPoolConstructorpoolOptions

Session pool configuration options.

spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptionsqueryOptions

Default query options to use with the database. These options will be overridden by any query options set in environment variables or that are specified on a per-query basis. {Database} A Database object.

Returns
TypeDescription
Database

delete(gaxOptions)

delete(gaxOptions?: CallOptions): Promise<DeleteInstanceResponse>;
Parameter
TypeNameDescription
CallOptionsgaxOptions
Returns
TypeDescription
Promise<DeleteInstanceResponse>

delete(callback)

delete(callback: DeleteInstanceCallback): void;
Parameter
TypeNameDescription
DeleteInstanceCallbackcallback
Returns
TypeDescription
void

delete(gaxOptions, callback)

delete(gaxOptions: CallOptions, callback: DeleteInstanceCallback): void;
Parameters
TypeNameDescription
CallOptionsgaxOptions
DeleteInstanceCallbackcallback
Returns
TypeDescription
void

exists(gaxOptions)

exists(gaxOptions?: CallOptions): Promise<ExistsInstanceResponse>;
Parameter
TypeNameDescription
CallOptionsgaxOptions
Returns
TypeDescription
Promise<ExistsInstanceResponse>

exists(callback)

exists(callback: ExistsInstanceCallback): void;
Parameter
TypeNameDescription
ExistsInstanceCallbackcallback
Returns
TypeDescription
void

exists(gaxOptions, callback)

exists(gaxOptions: CallOptions, callback: ExistsInstanceCallback): void;
Parameters
TypeNameDescription
CallOptionsgaxOptions
ExistsInstanceCallbackcallback
Returns
TypeDescription
void

formatName_(projectId, name)

static formatName_(projectId: string, name: string): string;

Format the instance name to include the project ID.

Parameters
TypeNameDescription
stringprojectId

The project ID.

stringname

The instance name.

Returns
TypeDescription
string

{string}

get(options)

get(options?: GetInstanceConfig): Promise<GetInstanceResponse>;
Parameter
TypeNameDescription
GetInstanceConfigoptions
Returns
TypeDescription
Promise<GetInstanceResponse>

get(callback)

get(callback: GetInstanceCallback): void;
Parameter
TypeNameDescription
GetInstanceCallbackcallback
Returns
TypeDescription
void

get(options, callback)

get(options: GetInstanceConfig, callback: GetInstanceCallback): void;
Parameters
TypeNameDescription
GetInstanceConfigoptions
GetInstanceCallbackcallback
Returns
TypeDescription
void

getBackupOperations(options)

getBackupOperations(options?: GetBackupOperationsOptions): Promise<GetBackupOperationsResponse>;
Parameter
TypeNameDescription
GetBackupOperationsOptionsoptions
Returns
TypeDescription
Promise<GetBackupOperationsResponse>

getBackupOperations(callback)

getBackupOperations(callback: GetBackupOperationsCallback): void;
Parameter
TypeNameDescription
GetBackupOperationsCallbackcallback
Returns
TypeDescription
void

getBackupOperations(options, callback)

getBackupOperations(options: GetBackupOperationsOptions, callback: GetBackupOperationsCallback): void;
Parameters
TypeNameDescription
GetBackupOperationsOptionsoptions
GetBackupOperationsCallbackcallback
Returns
TypeDescription
void

getBackups(options)

getBackups(options?: GetBackupsOptions): Promise<GetBackupsResponse>;
Parameter
TypeNameDescription
GetBackupsOptionsoptions
Returns
TypeDescription
Promise<GetBackupsResponse>

getBackups(callback)

getBackups(callback: GetBackupsCallback): void;
Parameter
TypeNameDescription
GetBackupsCallbackcallback
Returns
TypeDescription
void

getBackups(options, callback)

getBackups(options: GetBackupsOptions, callback: GetBackupsCallback): void;
Parameters
TypeNameDescription
GetBackupsOptionsoptions
GetBackupsCallbackcallback
Returns
TypeDescription
void

getBackupsStream(options)

getBackupsStream(options?: GetBackupsOptions): NodeJS.ReadableStream;

Get a list of backups as a readable object stream.

Wrapper around .

[ListBackups API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.ListBackups)

Spanner#getBackupsStream

Parameter
TypeNameDescription
GetBackupsOptionsoptions

Query object for listing backups.

Returns
TypeDescription
NodeJS.ReadableStream

{ReadableStream} A readable stream that emits Backup instances.

getDatabaseOperations(options)

getDatabaseOperations(options?: GetDatabaseOperationsOptions): Promise<GetDatabaseOperationsResponse>;
Parameter
TypeNameDescription
GetDatabaseOperationsOptionsoptions
Returns
TypeDescription
Promise<GetDatabaseOperationsResponse>

getDatabaseOperations(callback)

getDatabaseOperations(callback: GetDatabaseOperationsCallback): void;
Parameter
TypeNameDescription
GetDatabaseOperationsCallbackcallback
Returns
TypeDescription
void

getDatabaseOperations(options, callback)

getDatabaseOperations(options: GetDatabaseOperationsOptions, callback: GetDatabaseOperationsCallback): void;
Parameters
TypeNameDescription
GetDatabaseOperationsOptionsoptions
GetDatabaseOperationsCallbackcallback
Returns
TypeDescription
void

getDatabases(options)

getDatabases(options?: GetDatabasesOptions): Promise<GetDatabasesResponse>;
Parameter
TypeNameDescription
GetDatabasesOptionsoptions
Returns
TypeDescription
Promise<GetDatabasesResponse>

getDatabases(callback)

getDatabases(callback: GetDatabasesCallback): void;
Parameter
TypeNameDescription
GetDatabasesCallbackcallback
Returns
TypeDescription
void

getDatabases(options, callback)

getDatabases(options: GetDatabasesOptions, callback: GetDatabasesCallback): void;
Parameters
TypeNameDescription
GetDatabasesOptionsoptions
GetDatabasesCallbackcallback
Returns
TypeDescription
void

getDatabasesStream(options)

getDatabasesStream(options?: GetDatabasesOptions): NodeJS.ReadableStream;

Get a list of databases as a readable object stream.

Wrapper around .

[ListDatabases API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases)

Spanner#getDatabasesStream

Parameter
TypeNameDescription
GetDatabasesOptionsoptions

Query object for listing databases.

Returns
TypeDescription
NodeJS.ReadableStream

{ReadableStream} A readable stream that emits Database instances.

getMetadata(options)

getMetadata(options?: GetInstanceMetadataOptions): Promise<GetInstanceMetadataResponse>;
Parameter
TypeNameDescription
GetInstanceMetadataOptionsoptions
Returns
TypeDescription
Promise<GetInstanceMetadataResponse>

getMetadata(callback)

getMetadata(callback: GetInstanceMetadataCallback): void;
Parameter
TypeNameDescription
GetInstanceMetadataCallbackcallback
Returns
TypeDescription
void

getMetadata(options, callback)

getMetadata(options: GetInstanceMetadataOptions, callback: GetInstanceMetadataCallback): void;
Parameters
TypeNameDescription
GetInstanceMetadataOptionsoptions
GetInstanceMetadataCallbackcallback
Returns
TypeDescription
void

setMetadata(metadata, gaxOptions)

setMetadata(metadata: IInstance, gaxOptions?: CallOptions): Promise<SetInstanceMetadataResponse>;
Parameters
TypeNameDescription
IInstancemetadata
CallOptionsgaxOptions
Returns
TypeDescription
Promise<SetInstanceMetadataResponse>

setMetadata(metadata, callback)

setMetadata(metadata: IInstance, callback: SetInstanceMetadataCallback): void;
Parameters
TypeNameDescription
IInstancemetadata
SetInstanceMetadataCallbackcallback
Returns
TypeDescription
void

setMetadata(metadata, gaxOptions, callback)

setMetadata(metadata: IInstance, gaxOptions: CallOptions, callback: SetInstanceMetadataCallback): void;
Parameters
TypeNameDescription
IInstancemetadata
CallOptionsgaxOptions
SetInstanceMetadataCallbackcallback
Returns
TypeDescription
void