INNER CODE UNIT · Swift
MeowDatabase
orlandos-nl/MongoKitten · Sources/Meow/Database.swift:15
public class MeowDatabase: @unchecked Sendable {
public let raw: MongoDatabase
public init(_ database: MongoDatabase) {
self.raw = database
}
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