What is the best approach to restructuring route endpoints into an ORM framework?

As a newcomer to Angular, I find myself uncertain about what exactly qualifies as an endpoint and how it can be transformed into ORM. My current understanding suggests that an endpoint is where data is retrieved from a server, whether it's through an online API or a SQL database query.

After some research, I've learned that ORM simplifies coding by removing the need for direct SQL commands. But how does one actually implement this? And what if there isn't any SQL involved but instead a request made to an online API via a URL?

To provide context, my project involves working on a website built with Angular, which incorporates a combination of database, API, and UI elements. The API collects data from both external online APIs and local databases. Therefore, my inquiry focuses on how to revamp both types of endpoints in this scenario.

Answer №1

Object-Relational Mapping (ORM) provides a way to interact with objects and allows a framework to handle the conversion of objects into a format required by the database, as well as converting data from the database into objects. This process is independent of the user interface (UI), as it concerns the data layer or backend data tier. The controller and other components of the backend may not even need to be aware of the ORM.

The key abstraction is:

  1. You work with Model classes regardless of the type of database being used
  2. Data retrieved from the database or through online API calls will ultimately be represented as model objects that can be passed to the UI

The UI layer should not be concerned with how the backend acquires the necessary data for display. Instead, the structure should be based on common sense, domain knowledge, and specific requirements, rather than focusing on data retrieval methods within the backend.

This principle also extends to API endpoints. It is important to create them in a meaningful way for your application. For example:

// Sample API endpoints for an e-commerce site

/product/recommendations      // returns recommended products for a user
/product/categories           // returns product categories
/user/getCartItems            // returns a user's cart items
/orders/cancel                // cancels an order

Notice how the API endpoints are designed independently from the backend's data handling processes.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What process allows for this Twitter API response to be converted into HTML format automatically?

It is common knowledge that Twitter operates in an API-centric manner, meaning all Twitter apps retrieve their data through the API. Upon accessing (or .xml for those who prefer), a JSON formatted result with plaintext content and no additional formattin ...

Retrieve a set of associated items using Django ORM

Let's take a look at these Django models: class Car(Model): owner = ForeignKey(User) ... some other attributes ... class User(Model): # Django user model With a queryset of users in hand, is there a convenient method (like User.objects. ...

Difficulty with SailsJS Transmitting Information to View Template

I've been trying to establish a connection for hours but haven't had any luck. All I want to do is transfer some data from a controller to a view template. When I navigate the route without specifying a view template, the browser displays the da ...

Utilizing shared components across a Next.js application within a monorepo

Utilizing a monorepo to share types, DTOs, and other isomorphic app components from backend services (Nest.js) within the same mono repo has presented some challenges for me. In my setup, both the next.js app and nest.js app (which itself is a nest.js mono ...

How can I fill the data array of arrays using an Angular Table component?

I am struggling to populate an Angular Table with data in the array of arrays format. Despite my efforts, the code I have written does not seem to work. Any suggestions for a solution would be greatly appreciated. Here is the data that I am trying to popu ...

Express.js - Unfulfilled promises cause blocks and slow down subsequent GET requests in express (Node.js)

I currently have an active express application that listens for GET requests. Whenever a GET request is made, it promptly returns a success response and triggers the function asyncForLoop(), which resolves a promise after 5 seconds. Issue: The problem ari ...

The compiler is showing an error with code TS5023, indicating that the option 'strictTemplates' is not recognized

When trying to compile my Angular application (v10), I encountered the following error message. An unexpected issue has occurred: tsconfig.json:14:5 - error TS5023: Unknown compiler option 'strictTemplates'. 14 "strictTemplates": t ...

Building a Docker image for a Django application with MySQL integration

I'm currently in the process of setting up a docker environment for my django project. Here is my dockerfile : FROM python:3 ENV PYTHONUNBUFFERED=1 RUN apt-get install default-libmysqlclient-dev RUN mkdir /config ADD /config/requirements.txt ...

Integrating Angular with ng-select for item selection verification

Could someone help me with setting up this scenario? A user picks an option from the dropdown menu. The previous selection remains until a certain point is reached. The selected value is sent out through the @Output variable. The chosen value is then con ...

The slider does not appear in the correct format

I am struggling to make my slider display properly. Currently, it is showing one image after another instead of sliding. The images for the slider are stored in a database. Can someone suggest a suitable change to the code? I am using carousel-slider to ...

I am encountering challenges with React.js implemented in Typescript

Currently, I'm grappling with a challenge while establishing a design system in ReactJS utilizing TypeScript. The issue at hand pertains to correctly passing and returning types for my components. To address this, here are the steps I've taken so ...

Retrieve values from MySQL that have only appeared once, considering their uniqueness across multiple columns

My table has the following columns: KEY1, KEY2, KEY3, KEY6, PLT_ID There are instances where different KEY6 values share the same (KEY1, KEY2, KEY3, PLT_ID) values, such as: KEY1 KEY2 KEY3 KEY6 PLT_ID 1 1 1 X 1 1 1 1 Y 1 I am trying to filter ...

After 6 minutes of inactivity, queues are automatically deleted when the Android tablet enters standby mode

Once the client (also known as the browser) goes into sleep mode, it stops receiving new updates from the subscribed queue after about 6 minutes. Upon checking RabbitMQ Management, I noticed that the related queues (like stomp-subscription-MBSsZ9XB0XCScXbS ...

What is the process for detecting command line arguments within the package.json script section?

I am working with the package.json file, which includes the following script: { "scripts": { "test": "ng test", }, ... } Now, I need to execute the command below: npm run test --prod How can I determine if the flag - ...

Discover similar items within an array by utilizing async/await and promise.all

The value of filterdList.length always equals the total number of elements with the code provided below. As a result, this method consistently returns false because there is only one item in the table that matches the given name. async itemExists(name) : ...

Passing events from a parent component to dynamically created child components in Angular

UPDATE: I've decided to tackle this issue in a different way by retrieving dynamic child component values in the parent component's save() function, following the accepted answer. I am attempting to create a system where a parent component emits ...

Differentiating navigation design in various views of Angular 4

I am utilizing a shared navigation with content that changes via RouterModule. Is there a way to modify the design of the navigation in different views? <app-navigation></app-navigation> <router-outlet></router-outlet> For example ...

How should one properly deal with this situation when it comes to the 'ngChanges' function?

Providing a downloadable data to a child component using the @input value has been working smoothly. Users can click on the download link and the file is downloaded without any issues. However, when changes are detected and the ngOnChanges function is tri ...

Global installation of Angular 5 CLI causing functionality issues

After installing Angular's latest version using the command npm install -g @angular/cli@latest, I set the path in the environment variable as: PATH C:\Users\User\AppData\Roaming\npm\node_modules\@angular\cli&bs ...

What is the reason behind the varying results of MySQL union all when using nearly identical queries?

When I was running a query, the results were incorrect. After making some modifications, it started working properly. Take a look at the comparison below: ORIGINAL: (NOT WORKING) select username, password from tbl_user union all select username as passwo ...