Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the missing find overload when decoding a Query: MongoKittenQuery directly into a Decodable type #338

Merged
merged 1 commit into from Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions Sources/MongoKitten/CollectionHelpers/Collection+Find.swift
Expand Up @@ -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<D: Decodable, Query: MongoKittenQuery>(_ query: Query, as type: D.Type) -> MappedCursor<FindQueryBuilder, D> {
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
Expand Down