loopbackio / loopbackio/loopback-next

Loopback-Filter parsing function needed

Open
#7,013 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I'm looking for a method (or set of methods) which parse the Filter-Objects into an actual SQL query string.

Examples:

{"where": {"NEKDNR": {"inq": [93006]}}}
  => WHERE NEKDNR IN (93006)
{"where": {"or": [{"NEARTNR": {"inq": [140000]}},{"NEKDNR": 93006} ]}} 
  => WHERE NEARTNR IN (140000) OR NEKDNR = 93006
{"where":{"or":[{"and":[{"NEARTNR":{"inq":[140000]}},{"NEKDNR":93006}]},{"NEARTNR":{"inq":[20000]}}]}}
  => WHERE (NEARTNR IN 140000 AND NEKDNR = 93006) OR NEARTNR IN 20000

We have the problem, that we have requests providing Filter objects like above, but the repository has to be refactored using a specialized SQL instead of the built in find-method. But now we are unable to easily add the WHERE-part to the SQL because, it's really complicated to parse the filter object.

So, is there such a method providing the SQL from a filter object which can be required in our sourcecode?

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 identified in the issue. Start by locating the existing Filter-object handling and determine how the shown nested where, or, and and examples should map to SQL; done means a reusable method is available for callers that need to add a filter-derived WHERE clause.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.