class SchemaManager (View source)

Constants

GRIDFS_FILE_COLLECTION_INDEX

GRIDFS_CHUNKS_COLLECTION_INDEX

CODE_SHARDING_ALREADY_INITIALIZED

Properties

protected DocumentManager $dm
protected ClassMetadataFactory $metadataFactory

Methods

ensureIndexes(int|null $timeout = null)

Ensure indexes are created for all documents that can be loaded with the metadata factory.

updateIndexes(int|null $timeout = null)

Ensure indexes exist for all mapped document classes.

updateDocumentIndexes(string $documentName, int|null $timeout = null)

Ensure indexes exist for the mapped document class.

getDocumentIndexes(string $documentName)

No description

ensureDocumentIndexes(string $documentName, int|null $timeoutMs = null)

Ensure the given document's indexes are created.

deleteIndexes()

Delete indexes for all documents that can be loaded with the metadata factory.

deleteDocumentIndexes(string $documentName)

Delete the given document's indexes.

createCollections()

Create all the mapped document collections in the metadata factory.

createDocumentCollection(string $documentName)

Create the document collection for a mapped class.

dropCollections()

Drop all the mapped document collections in the metadata factory.

dropDocumentCollection(string $documentName)

Drop the document collection for a mapped class.

dropDatabases()

Drop all the mapped document databases in the metadata factory.

dropDocumentDatabase(string $documentName)

Drop the document database for a mapped class.

isMongoIndexEquivalentToDocumentIndex($mongoIndex, array $documentIndex)

Determine if an index returned by MongoCollection::getIndexInfo() can be considered equivalent to an index in class metadata.

ensureSharding()

Ensure collections are sharded for all documents that can be loaded with the metadata factory.

ensureDocumentSharding(string $documentName)

Ensure sharding for collection by document name.

enableShardingForDbByDocumentName(string $documentName)

Enable sharding for database which contains documents with given name.

Details

__construct(DocumentManager $dm, ClassMetadataFactory $cmf)

ensureIndexes(int|null $timeout = null)

Ensure indexes are created for all documents that can be loaded with the metadata factory.

Parameters

int|null $timeout

updateIndexes(int|null $timeout = null)

Ensure indexes exist for all mapped document classes.

Indexes that exist in MongoDB but not the document metadata will be deleted.

Parameters

int|null $timeout

updateDocumentIndexes(string $documentName, int|null $timeout = null)

Ensure indexes exist for the mapped document class.

Indexes that exist in MongoDB but not the document metadata will be deleted.

Parameters

string $documentName
int|null $timeout

Exceptions

InvalidArgumentException

getDocumentIndexes(string $documentName)

Parameters

string $documentName

ensureDocumentIndexes(string $documentName, int|null $timeoutMs = null)

Ensure the given document's indexes are created.

Parameters

string $documentName
int|null $timeoutMs

Exceptions

InvalidArgumentException

deleteIndexes()

Delete indexes for all documents that can be loaded with the metadata factory.

deleteDocumentIndexes(string $documentName)

Delete the given document's indexes.

Parameters

string $documentName

Exceptions

InvalidArgumentException

createCollections()

Create all the mapped document collections in the metadata factory.

createDocumentCollection(string $documentName)

Create the document collection for a mapped class.

Parameters

string $documentName

Exceptions

InvalidArgumentException

dropCollections()

Drop all the mapped document collections in the metadata factory.

dropDocumentCollection(string $documentName)

Drop the document collection for a mapped class.

Parameters

string $documentName

Exceptions

InvalidArgumentException

dropDatabases()

Drop all the mapped document databases in the metadata factory.

dropDocumentDatabase(string $documentName)

Drop the document database for a mapped class.

Parameters

string $documentName

Exceptions

InvalidArgumentException

isMongoIndexEquivalentToDocumentIndex($mongoIndex, array $documentIndex)

Determine if an index returned by MongoCollection::getIndexInfo() can be considered equivalent to an index in class metadata.

Indexes are considered different if:

(a) Key/direction pairs differ or are not in the same order (b) Sparse or unique options differ (c) Mongo index is unique without dropDups and mapped index is unique with dropDups (d) Geospatial options differ (bits, max, min) (e) The partialFilterExpression differs

Regarding (c), the inverse case is not a reason to delete and recreate the index, since dropDups only affects creation of the unique index. Additionally, the background option is only relevant to index creation and is not considered.

Parameters

$mongoIndex
array $documentIndex

ensureSharding()

Ensure collections are sharded for all documents that can be loaded with the metadata factory.

Exceptions

MongoDBException

ensureDocumentSharding(string $documentName)

Ensure sharding for collection by document name.

Parameters

string $documentName

Exceptions

MongoDBException

enableShardingForDbByDocumentName(string $documentName)

Enable sharding for database which contains documents with given name.

Parameters

string $documentName

Exceptions

MongoDBException