Google Cloud Spanner C++ Client  1.32.1
A C++ Client Library for Google Cloud Spanner
Public Member Functions | List of all members
google::cloud::spanner::v1::Database Class Reference

This class identifies a Cloud Spanner Database. More...

#include <google/cloud/spanner/database.h>

Public Member Functions

 Database (Instance instance, std::string database_id)
 Constructs a Database object identified by the given instance and database_id. More...
 
 Database (std::string project_id, std::string instance_id, std::string database_id)
 Constructs a Database object identified by the given IDs. More...
 
Copy and move
 Database (Database const &)=default
 Returns the Instance containing this database. More...
 
Databaseoperator= (Database const &)=default
 Returns the Instance containing this database. More...
 
 Database (Database &&)=default
 Returns the Instance containing this database. More...
 
Databaseoperator= (Database &&)=default
 Returns the Instance containing this database. More...
 
Instance const & instance () const
 Returns the Instance containing this database. More...
 
std::string const & database_id () const
 Returns the Database ID. More...
 
std::string FullName () const
 Returns the fully qualified database name as a string of the form: "projects/<project-id>/instances/<instance-id>/databases/<database-id>". More...
 

Equality operators

bool operator== (Database const &a, Database const &b)
 Output the FullName() format. More...
 
bool operator!= (Database const &a, Database const &b)
 Output the FullName() format. More...
 
std::ostream & operator<< (std::ostream &, Database const &)
 Output the FullName() format. More...
 

Detailed Description

This class identifies a Cloud Spanner Database.

A Cloud Spanner database is identified by its project_id, instance_id, and database_id.

Note
This class makes no effort to validate the components of the database name. It is the application's responsibility to provide valid project, instance, and database ids. Passing invalid values will not be checked until the database name is used in a RPC to spanner.

For more info about the database_id format, see https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.CreateDatabaseRequest

Definition at line 43 of file database.h.

Constructor & Destructor Documentation

◆ Database() [1/4]

google::cloud::spanner::v1::Database::Database ( Instance  instance,
std::string  database_id 
)

Constructs a Database object identified by the given instance and database_id.

Definition at line 24 of file database.cc.

◆ Database() [2/4]

google::cloud::spanner::v1::Database::Database ( std::string  project_id,
std::string  instance_id,
std::string  database_id 
)

Constructs a Database object identified by the given IDs.

This is equivalent to first constructing an Instance from the given project_id and instance_id arguments and then calling the Database(Instance, std::string) constructor.

Definition at line 27 of file database.cc.

◆ Database() [3/4]

google::cloud::spanner::v1::Database::Database ( Database const &  )
default

Returns the Instance containing this database.

◆ Database() [4/4]

google::cloud::spanner::v1::Database::Database ( Database &&  )
default

Returns the Instance containing this database.

Member Function Documentation

◆ database_id()

std::string const& google::cloud::spanner::v1::Database::database_id ( ) const
inline

Returns the Database ID.

Definition at line 73 of file database.h.

◆ FullName()

std::string google::cloud::spanner::v1::Database::FullName ( ) const

Returns the fully qualified database name as a string of the form: "projects/<project-id>/instances/<instance-id>/databases/<database-id>".

Definition at line 32 of file database.cc.

◆ instance()

Instance const& google::cloud::spanner::v1::Database::instance ( ) const
inline

Returns the Instance containing this database.

Definition at line 70 of file database.h.

◆ operator=() [1/2]

Database& google::cloud::spanner::v1::Database::operator= ( Database &&  )
default

Returns the Instance containing this database.

◆ operator=() [2/2]

Database& google::cloud::spanner::v1::Database::operator= ( Database const &  )
default

Returns the Instance containing this database.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( Database const &  a,
Database const &  b 
)
friend

Output the FullName() format.

Definition at line 40 of file database.cc.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
Database const &  db 
)
friend

Output the FullName() format.

Definition at line 42 of file database.cc.

◆ operator==

bool operator== ( Database const &  a,
Database const &  b 
)
friend

Output the FullName() format.

Definition at line 36 of file database.cc.