Skip to content

Commit 4c90d31

Browse files
committed
effect-mongodb: add known limitations to README.md
1 parent b45c58a commit 4c90d31

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/effect-mongodb/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,20 @@ All cursor modules provide, at least, two functions:
8282
For document-based modules, these functions can only fail with a `MongoError`, while for schema-based modules, they can
8383
fail also with a `ParseError`. For this reason, the schema-based modules provide two additional functions:
8484
`toArrayEither` and `toStreamEither`. These functions return, respectively, an array and a stream of `Either`s, allowing
85-
the code to process all the documents, even if some of them are invalid.
85+
the code to process all the documents, even if some of them are invalid.
86+
87+
## Known limitations
88+
89+
### Filters for Schema-based operations
90+
91+
Using `Filter` in schema-based operations (e.g. `find`, `deleteOne`, etc.) is not as straightforward as in
92+
document-based operations.
93+
Given a `Schema<A, I, R>`, `A` is the runtime/decoded type of the documents, while `I` is the persisted/encoded type of
94+
the same documents.
95+
Therefore, to filter documents in MongoDB, the client must provide a filter of type `Filter<I>`, where `Filter` is the
96+
type provided by the MongoDB driver.
97+
98+
A better approach, given the design of the Schema-based operations, would be to provide filters as `Filter<A>`, but
99+
we didn't yet find a straightforward way to map `Filter<A>` to `Filter<I>`.
100+
For this reason, we decided to keep the original MongoDB filter type.
101+
In the future, this may (hopefully) change.

0 commit comments

Comments
 (0)