class SchemaManager (View source)

Properties

protected DocumentManager $dm
protected ClassMetadataFactory $metadataFactory

Methods

ensureIndexes(int $timeout = null)

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

updateIndexes(int $timeout = null)

Ensure indexes exist for all mapped document classes.

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

Ensure indexes exist for the mapped document class.

array
getDocumentIndexes(string $documentName)

No description

ensureDocumentIndexes(string $documentName, int $timeout = 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.

bool
isMongoIndexEquivalentToDocumentIndex(array|IndexInfo $mongoIndex, array $documentIndex)

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

ensureSharding(array $indexOptions = [])

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

ensureDocumentSharding(string $documentName, array $indexOptions = [])

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 $timeout = null)

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

Parameters

int $timeout Timeout (ms) for acknowledged index creation

updateIndexes(int $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 $timeout Timeout (ms) for acknowledged index creation

updateDocumentIndexes(string $documentName, int $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 $timeout Timeout (ms) for acknowledged index creation

Exceptions

InvalidArgumentException

array getDocumentIndexes(string $documentName)

Parameters

string $documentName

Return Value

array

ensureDocumentIndexes(string $documentName, int $timeout = null)

Ensure the given document's indexes are created.

Parameters

string $documentName
int $timeout Timeout (ms) for acknowledged index creation

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

bool isMongoIndexEquivalentToDocumentIndex(array|IndexInfo $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

array|IndexInfo $mongoIndex Mongo index data.
array $documentIndex Document index data.

Return Value

bool True if the indexes are equivalent, otherwise false.

ensureSharding(array $indexOptions = [])

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

Parameters

array $indexOptions Options for ensureIndex command. It's performed on an existing collections

Exceptions

MongoDBException

ensureDocumentSharding(string $documentName, array $indexOptions = [])

Ensure sharding for collection by document name.

Parameters

string $documentName
array $indexOptions Options for ensureIndex command. It's performed on an existing collections.

Exceptions

MongoDBException

enableShardingForDbByDocumentName(string $documentName)

Enable sharding for database which contains documents with given name.

Parameters

string $documentName

Exceptions

MongoDBException