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 ) -> DocumentCollection
Return Value
A reference to the newly created collection.
-
Retrieves a
DocumentCollection
with the specified name.Declaration
Swift
public func getCollection(named name: String) -> DocumentCollection?
Parameters
name
The name of the collection to retrieve.
Return Value
The
DocumentCollection
associated with the given name, ornil
if 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 throws
Parameters
name
The name of the collection to be removed.
storage
The 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 throws
Parameters
name
The name of the collection to update.
storage
The storage engine to be used for the collection.
partitionKey
The 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
DocumentCollection
instances currently stored in the catalog.