generated from jackyzha0/quartz
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs/core): 2024-12-16 15:03:55
Affected files: content/Projects/GC/API Reference/Codebase Infrastructure.md content/Projects/GC/API Reference/Interacting with generated services.md
- Loading branch information
Showing
2 changed files
with
14 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
content/Projects/GC/API Reference/Interacting with generated services.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
In the Repository, the `GlobalService` class provides a set of robust methods to interact with the database in a clean and efficient manner, aligning with the philosophy of simplicity and flexibility, which is heavily inspired by the Feathers.js framework. The methods available—`_find`, `_create`, `_patch`, `_get`, and `_remove`—serve as the core tools for performing CRUD (Create, Read, Update, Delete) operations. | ||
|
||
1. `_find`: This method allows for querying and retrieving data based on specific query options, such as filtering, sorting, and pagination. It is designed to work efficiently with large datasets, enabling developers to fetch only the data they need. This aligns with Feathers.js's philosophy of making data fetching and manipulation as flexible as possible. | ||
|
||
2. `_create`: This method is used for creating new records, whether it's a single record or multiple records at once. It provides a simple, consistent way to handle record creation, reducing the complexity of having to write repetitive logic for inserting new data. Feathers.js’s philosophy of "convention over configuration" is evident here, as it abstracts much of the complexity. | ||
|
||
3. `_patch`: This method updates existing records, allowing partial updates. This is particularly useful for making modifications to only certain fields of a record without needing to resend the entire data. This method promotes the Feathers approach of efficient updates, ensuring minimal data transfer and server load. | ||
|
||
4. `_get`: This method retrieves a single record based on its unique identifier. It provides a quick and simple way to fetch specific records when needed. This simplicity and directness in accessing individual records follow Feathers’ focus on making common tasks like fetching data as straightforward as possible. | ||
|
||
5. `_remove`: This method handles the deletion of records, either through soft deletes (marking records as deleted without actually removing them from the database) or hard deletes (completely removing the records). This method offers flexibility in managing data integrity, allowing developers to decide the best approach for data deletion. | ||
|
||
The overall benefit of using these methods is that they provide a consistent, reusable interface for database interactions. They allow developers to focus more on business logic rather than on writing repetitive database code. Additionally, this approach promotes clean, maintainable code that can scale with the application's growth. By adopting Feathers.js's philosophy, the `GlobalService` ensures that operations are lightweight, flexible, and efficient, aligning with the principles of RESTful APIs and making it easier for developers to build, maintain, and scale applications. |