From fded24e9ed25d69112f486135913516f6b667b0e Mon Sep 17 00:00:00 2001 From: Joannis Orlandos Date: Tue, 19 Mar 2024 15:13:39 +0100 Subject: [PATCH] Add the missing `find` overload when decoding a Query: MongoKittenQuery directly into a Decodable type --- .../MongoKitten/CollectionHelpers/Collection+Find.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/MongoKitten/CollectionHelpers/Collection+Find.swift b/Sources/MongoKitten/CollectionHelpers/Collection+Find.swift index 90ed4aa3..9bc9e07d 100644 --- a/Sources/MongoKitten/CollectionHelpers/Collection+Find.swift +++ b/Sources/MongoKitten/CollectionHelpers/Collection+Find.swift @@ -34,6 +34,13 @@ extension MongoCollection { return find(query).decode(type) } + /// Finds documents in this collection matching the given query. If no query is given, it returns all documents in the collection. Decodes the results to the given type. + /// - Parameter query: The query to match documents against + /// - Returns: A cursor to iterate over the results + public func find(_ query: Query, as type: D.Type) -> MappedCursor { + return find(query).decode(type) + } + /// Finds the first document in this collection matching the given query. Decodes the result into `D.Type`. /// - Parameter query: The query to match documents against /// - Parameter type: The type to decode the document to