INNER CODE UNIT · Swift

collection

orlandos-nl/MongoKitten · Sources/Meow/Database.swift:22

    public func collection<M: BaseModel>(for model: M.Type) -> MeowCollection<M> {
        return MeowCollection<M>(database: self, named: M.collectionName)
    }
    
    public subscript<M: BaseModel>(type: M.Type) -> MeowCollection<M> {
        return collection(for: type)
    }
    
    /// Creates a transaction database, with which the same queries can be done with the same APis as this object.
    /// If an error in thrown within `perform`, the transaction is aborted
    /// It's automaticalyl committed if successful
    public func withTransaction<T>(
        with options: MongoSessionOptions = .init(),
        transactionOptions: MongoTransactionOptions? = nil,
        perform: (MeowTransactionDatabase) async throws -> T
    ) async throws -> T {
        let transaction = try await raw.startTransaction(autoCommitChanges: false, with: options, transactionOptions: transactionOptions)
        let meowDatabase = MeowTransactionDatabase(transaction)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…