[DRIVERS-960] Allow filter to be an Optional argument Created: 20/Nov/19  Updated: 31/Mar/20  Resolved: 31/Mar/20

Status: Closed
Project: Drivers
Component/s: CRUD
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Patrick Freed Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Right now, the crud spec defines the method signature for find as the following:

find(filter: Document, options: Optional<FindOptions>): Iterable<Document> 

which implies that filter cannot be Optional<Document>.

Would it be acceptable for drivers to accept this filter as an optional so that users won't have to specify the empty document when they want to match all documents? Or is this distinction intentional?

As sam.rossi points out, there already is precedent for this in several drivers (e.g. Java via overloading, Python via accepting None).



 Comments   
Comment by Bernie Hackett [ 20/Nov/19 ]

Food for thought:

  • The Java and Python drivers predate the spec by many many years. We didn't want to break existing applications in the name of spec compliance.
  • In general, I think we want to strive for consistency. countDocuments, for example, always requires a document even if the document is empty. aggregate always requires a pipeline, even if the pipeline is empty.
Generated at Thu Feb 08 08:22:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.