You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(README): enhance ID management explanation and feature highlights
- Add detailed explanation of ID management strategy in the introduction
- Expand bullet points to highlight ID management and support for different data models
- Remove duplicate license section
Copy file name to clipboardExpand all lines: README.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@ A production-ready MongoDB implementation of the `HtDataClient` interface, desig
12
12
13
13
It translates the abstract, high-level data requests from the `HtDataClient` interface—including rich filters, multi-field sorting, and cursor-based pagination—into native, efficient MongoDB queries.
14
14
15
+
A key feature of this implementation is its **ID management strategy**. It ensures that the application layer remains the source of truth for a document's ID by mapping the model's `id` string to the database's `_id` field. This is crucial for correctly handling both global documents (like headlines) and user-owned documents (like settings), where the document's `_id` must match the user's ID. For a deeper explanation, see the documentation within the `HtDataMongodb` class.
16
+
15
17
## Getting Started
16
18
17
19
This package is intended to be used as a dependency in backend services (like a Dart Frog API) or applications that connect directly to MongoDB.
@@ -43,12 +45,11 @@ Then run `dart pub get` or `flutter pub get`.
43
45
- Implements the `HtDataClient<T>` interface from `package:ht_data_client`.
44
46
- Includes `MongoDbConnectionManager` for robust connection lifecycle management.
-Automatically handles the mapping between your models' `String id`and MongoDB's `ObjectId _id`.
47
-
- Supports both user-scoped and global data operations.
48
+
-**Handles ID Management**: Faithfully maps the application-level `id`string to the database `_id`, preserving data integrity for all document types.
49
+
-**Supports Multiple Data Models**: Correctly handles both global documents (e.g., `Headline`) and user-owned documents (e.g., `UserAppSettings`) where the document `_id` serves as the foreign key to the user.
48
50
- Throws standard exceptions from `package:ht_shared` for consistent error handling.
49
51
- Implements `count` for efficient document counting.
50
-
- Implements `aggregate` to execute powerful, server-side aggregation
51
-
pipelines, automatically scoping to a `userId` when provided.
52
+
- Implements `aggregate` to execute powerful, server-side aggregation pipelines.
52
53
53
54
## Usage
54
55
@@ -142,4 +143,4 @@ void main() async {
142
143
143
144
## License
144
145
145
-
This package is licensed under the [PolyForm Free Trial 1.0.0](/LICENSE). Please review the terms before use.
146
+
This package is licensed under the [PolyForm Free Trial 1.0.0](/LICENSE). Please review the terms before use.
0 commit comments