loopbackio / loopbackio/loopback-next

How to perform joins on non-primary columns and complex select statements in loopback 4?

Open
#9,503 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

Describe the bug

Hi i am new to loopback and need to create an API with business logic that contains several complex queries. I cant seem to find a way to join two tables with non-primary columns. For example, select * from e_c left join e on e.ed=e_c.ed Table relations: e_c.ed fk to ed table on id e.ed fk to ed table on id

On the same note writing complex select statements are also needed. For example, select (case when completed_on is null then 1 else 0 end) flag from e or select sum(rating) from f_b

Kindly provide some method by which these can be achieved via loopback 4

Logs

No response

Additional information

No response

Reproduction

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file, test, or entry point is named. Start by reviewing LoopBack 4 relation and query APIs against the non-primary-column join and complex SELECT examples; done means identifying a documented supported approach or clearly documenting the limitation and required scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.