Skip to content

Commit

Permalink
chore(docs/core): 2024-12-16 15:03:55
Browse files Browse the repository at this point in the history
Affected files:
content/Projects/GC/API Reference/Codebase Infrastructure.md
content/Projects/GC/API Reference/Interacting with generated services.md
  • Loading branch information
zakhaev26 committed Dec 16, 2024
1 parent c67ae3a commit ebfa2b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ The main source code directory for the application:

1. **`common/`**:

- Utility functions, reusable components, and shared services (e.g., `mailer.ts` for sending emails, `soft-delete-schema.ts` for handling soft deletes).
- Utility functions, reusable components, and shared services (e.g., `mailer.ts` for sending emails, `soft-delete-schema.ts` for handling soft deletes),etc.
2. **`constants/`**:

- **`roles-enum.ts`**: Enum definitions for user roles.
Expand Down
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.

0 comments on commit ebfa2b0

Please sign in to comment.