CollectionCatalog
public class CollectionCatalog
A singleton class responsible for managing and providing access to document collections.
The CollectionCatalog class maintains a registry of collections, allowing for centralized
management and retrieval of DocumentCollection instances. It is designed as a singleton
to ensure a single, globally accessible instance throughout the application.
-
Undocumented
Declaration
Swift
public static let shared: CollectionCatalog -
Creates a new collection with the specified parameters.
Throws
An error if the collection cannot be created, such as if a collection with the same name already exists or if there is an issue with the provided options.Declaration
Swift
public func createCollection( storage: StorageEngine, statsEngine: StatsEngine, name: String, indexes: [String] = [], partitionKey: String ) -> DocumentCollectionReturn Value
A reference to the newly created collection.
-
Retrieves a
DocumentCollectionwith the specified name.Declaration
Swift
public func getCollection(named name: String) -> DocumentCollection?Parameters
nameThe name of the collection to retrieve.
Return Value
The
DocumentCollectionassociated with the given name, ornilif no such collection exists. -
removeCollection(named:Asynchronousstorage: ) Removes a collection with the specified name from the storage engine.
Throws
An error if the operation fails.Note
This is an asynchronous function and must be called withawait.Declaration
Swift
public func removeCollection(named name: String, storage: StorageEngine) async throwsParameters
nameThe name of the collection to be removed.
storageThe storage engine instance where the collection resides.
-
Updates the configuration of a collection with the specified name.
Throws
An error if the update operation fails.Note
This is an asynchronous operation.Declaration
Swift
public func updateCollectionConfiguration( named name: String, storage: StorageEngine, partitionKey: String ) async throwsParameters
nameThe name of the collection to update.
storageThe storage engine to be used for the collection.
partitionKeyThe partition key to be used for the collection.
-
Retrieves a list of all document collections.
Declaration
Swift
public func listCollections() -> [DocumentCollection]Return Value
An array containing all
DocumentCollectioninstances currently stored in the catalog.
View on GitHub