Instance Method
find(inDB:selector:dateDecodingStrategy:eventLoopGroup:)
Performs a query using a selector payload and decodes the matching documents.
func find<T>(inDB dbName: String, selector: any Codable, dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .secondsSince1970, eventLoopGroup: (any EventLoopGroup)? = nil) async throws -> [T] where T : CouchDBRepresentable
Deprecated
Use find(inDB:query:) instead
Parameters
- dbName
The name of the database in which to perform the query.
- selector
A Codable object that defines the criteria for selecting documents.
- dateDecodingStrategy
The date decoding strategy to use for decoding dates within the documents. Defaults to .secondsSince1970.
- eventLoopGroup
An optional EventLoopGroup for executing network operations. If not provided, the function defaults to using a shared instance of HTTPClient.
Return Value
An array of documents of type T, where T conforms to CouchDBRepresentable.
Discussion
This deprecated compatibility overload accepts an arbitrary selector payload, sends it to CouchDB’s _find endpoint, and decodes the resulting documents into the requested CouchDBRepresentable type.
Throws
A CouchDBClientError if authentication fails, the response body is missing, or CouchDB returns an error payload that maps to .findError(error:). Non-CouchDB decoding failures are propagated as the underlying decoding error.
Example Usage:
let selector = ["selector": ["name": "Sam"]]
let documents: [MyDocumentType] = try await couchDBClient.find(
inDB: "myDatabase",
selector: selector
)
print(documents)
Note
Prefer find(inDB:query:dateDecodingStrategy:eventLoopGroup:) for a type-safe Mango query API.