Skip to content

Commit 80ff148

Browse files
committed
effect-mongodb: rephrase Design decisions Document-based and Schema-based API
1 parent fd96037 commit 80ff148

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

packages/effect-mongodb/README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,23 @@ Here is a list of design decisions made and principles followed while developing
5454
1. `Option` is used instead of `null` or `undefined` values.
5555
2. Some operation options, which have an impact on the shape of API response, may be replaced with stricter functions
5656
(e.g. `projection` in `find` operation).
57-
3. **Schema-based vs Document-based**: the package provides two sets of functions.
58-
59-
The first set is based on MongoDB's `Document` type, therefore, without any runtime validation on the shape of the
60-
document, and signatures mostly identical to those of the original APIs.
57+
3. **Document-based API**: these API are based on MongoDB's `Document` type, therefore, without any runtime validation
58+
on the shape of the document.
59+
60+
Signatures are mostly identical to those of the original APIs.
61+
6162
All modules belonging to this set are prefixed with `Document`, e.g. `DocumentCollection` or `DocumentFindCursor`.
62-
63-
The second set is based on Schema, therefore, provides runtime validation.
64-
Its functions may have slightly different signatures than the original APIs, since they enforce stricter types than
65-
the first set.
63+
64+
These API are mainly useful for incremental adoption in existing codebases, and to allow quick prototyping when validation is redundant.
65+
4. **Schema-based API**: these API are based on Schema, therefore, provides runtime validation.
66+
67+
Functions may have slightly different signatures than the original APIs, since they enforce stricter types than
68+
the Document-based API.
69+
6670
All modules belonging to this set don't have any prefix, e.g. `Collection` or `FindCursor`.
71+
6772
While developing the package, this set of functions is the one we put more effort into.
68-
4. **Error handling**: we introduced a new error type `MongoError`, derived from
73+
5. **Error handling**: we introduced a new error type `MongoError`, derived from
6974
[`TaggedError`](https://effect.website/docs/data-types/data/#taggederror), to wrap the original MongoDB errors.
7075
The current implementation is basic, but it will be extended to provide more detailed information and a finer error
7176
handling.

0 commit comments

Comments
 (0)