![]() |
Storage Engine API
|
Represents a logical database containing Collections. More...
#include <database.h>
Represents a logical database containing Collections.
The semantics for a const Database are that you can mutate individual collections but not add or remove them.
Classes | |
class | Impl |
class | iterator |
Iterating over a Database yields Collection* pointers. More... | |
struct | TUHook |
Public Types | |
typedef StringMap< Collection * > | CollectionMap |
Public Member Functions | |
Database (OperationContext *const opCtx, const StringData name, DatabaseCatalogEntry *const dbEntry) | |
~Database ()=default | |
Database (Database &&)=delete | |
Database & | operator= (Database &&)=delete |
iterator | begin () const |
iterator | end () const |
void | close (OperationContext *const opCtx, const std::string &reason) |
const std::string & | name () const |
void | clearTmpCollections (OperationContext *const opCtx) |
Status | setProfilingLevel (OperationContext *const opCtx, const int newLevel) |
Sets a new profiling level for the database and returns the outcome. More... | |
int | getProfilingLevel () const |
const char * | getProfilingNS () const |
void | setDropPending (OperationContext *opCtx, bool dropPending) |
Sets the 'drop-pending' state of this Database. More... | |
bool | isDropPending (OperationContext *opCtx) const |
Returns the 'drop-pending' state of this Database. More... | |
void | getStats (OperationContext *const opCtx, BSONObjBuilder *const output, const double scale=1) |
const DatabaseCatalogEntry * | getDatabaseCatalogEntry () const |
Status | dropCollection (OperationContext *const opCtx, const StringData fullns, repl::OpTime dropOpTime={}) |
dropCollection() will refuse to drop system collections. More... | |
Status | dropCollectionEvenIfSystem (OperationContext *const opCtx, const NamespaceString &fullns, repl::OpTime dropOpTime={}) |
Status | dropView (OperationContext *const opCtx, const StringData fullns) |
Collection * | createCollection (OperationContext *const opCtx, StringData ns, const CollectionOptions &options=CollectionOptions(), const bool createDefaultIndexes=true, const BSONObj &idIndex=BSONObj()) |
Status | createView (OperationContext *const opCtx, const StringData viewName, const CollectionOptions &options) |
Collection * | getCollection (OperationContext *opCtx, const StringData ns) const |
Collection * | getCollection (OperationContext *opCtx, const NamespaceString &ns) const |
ViewCatalog * | getViewCatalog () |
Get the view catalog, which holds the definition for all views created on this database. More... | |
Collection * | getOrCreateCollection (OperationContext *const opCtx, const NamespaceString &nss) |
Status | renameCollection (OperationContext *const opCtx, const StringData fromNS, const StringData toNS, const bool stayTemp) |
const NamespaceString & | getSystemIndexesName () const |
const std::string & | getSystemViewsName () const |
StatusWith< NamespaceString > | makeUniqueCollectionNamespace (OperationContext *opCtx, StringData collectionNameModel) |
Generates a collection namespace suitable for creating a temporary collection. More... | |
Static Public Member Functions | |
static | MONGO_DECLARE_SHIM ((OperationContext *opCtx) ->void) dropAllDatabasesExceptLocal |
static | MONGO_DECLARE_SHIM ((OperationContext *opCtx, Database *db, StringData ns, BSONObj options, CollectionOptions::ParseKind parseKind=CollectionOptions::parseForCommand, bool createDefaultIndexes=true, const BSONObj &idIndex=BSONObj()) ->Status) userCreateNS |
Creates the namespace 'ns' in the database 'db' according to 'options'. More... | |
static | MONGO_DECLARE_SHIM ((Database *this_, OperationContext *opCtx, StringData name, DatabaseCatalogEntry *, PrivateTo< Database >) ->std::unique_ptr< Impl >) makeImpl |
static | MONGO_DECLARE_SHIM ((OperationContext *opCtx, Database *db) ->void) dropDatabase |
Physically drops the specified opened database and removes it from the server's metadata. More... | |
Private Member Functions | |
const Impl & | _impl () const |
Impl & | _impl () |
Private Attributes | |
std::unique_ptr< Impl > | _pimpl |
typedef StringMap<Collection*> mongo::Database::CollectionMap |
|
inlineexplicit |
|
inlinedefault |
|
inlinedelete |
|
inlineprivate |
|
inlineprivate |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
dropCollection() will refuse to drop system collections.
Use dropCollectionEvenIfSystem() if that is required.
If we are applying a 'drop' oplog entry on a secondary, 'dropOpTime' will contain the optime of the oplog entry.
|
inline |
|
inline |
|
inline |
|
inline |
ns | - this is fully qualified, which is maybe not ideal ??? |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the view catalog, which holds the definition for all views created on this database.
You must be holding a database lock to use this accessor.
|
inline |
Returns the 'drop-pending' state of this Database.
The database must be locked in MODE_X when calling this function.
|
inline |
Generates a collection namespace suitable for creating a temporary collection.
The namespace is based on a model that replaces each percent sign in 'collectionNameModel' by a random character in the range [0-9A-Za-z]. Returns FailedToParse if 'collectionNameModel' does not contain any percent signs. Returns NamespaceExists if we are unable to generate a collection name that does not conflict with an existing collection in this database.
The database must be locked in MODE_X when calling this function.
|
static |
|
static |
Creates the namespace 'ns' in the database 'db' according to 'options'.
If 'createDefaultIndexes' is true, creates the _id index for the collection (and the system indexes, in the case of system collections). Creates the collection's _id index according to 'idIndex', if it is non-empty. When 'idIndex' is empty, creates the default _id index.
|
static |
|
static |
Physically drops the specified opened database and removes it from the server's metadata.
It doesn't notify the replication subsystem or do any other consistency checks, so it should not be used directly from user commands.
Must be called with the specified database locked in X mode.
|
inline |
|
inline |
|
inline |
Sets the 'drop-pending' state of this Database.
This is done at the beginning of a dropDatabase operation and is used to reject subsequent collection creation requests on this database. Throws a UserAssertion if this is called on a Database that is already in a 'drop-pending' state. The database must be locked in MODE_X when calling this function.
|
inline |
Sets a new profiling level for the database and returns the outcome.
opCtx | Operation context which to use for creating the profiling collection. |
newLevel | New profiling level to use. |
|
private |