Skip to content

Commit 925354e

Browse files
committed
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
1 parent 11bf43e commit 925354e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ A production-ready MongoDB implementation of the `HtDataClient` interface, desig
1212

1313
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.
1414

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+
1517
## Getting Started
1618

1719
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`.
4345
- Implements the `HtDataClient<T>` interface from `package:ht_data_client`.
4446
- Includes `MongoDbConnectionManager` for robust connection lifecycle management.
4547
- Translates `readAll` parameters (`filter`, `sort`, `pagination`) into native MongoDB queries.
46-
- 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.
4850
- Throws standard exceptions from `package:ht_shared` for consistent error handling.
4951
- 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.
5253

5354
## Usage
5455

@@ -142,4 +143,4 @@ void main() async {
142143

143144
## License
144145

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

Comments
 (0)