Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliases/expansions research #8

Open
kirrg001 opened this issue Dec 12, 2018 · 0 comments
Open

Aliases/expansions research #8

kirrg001 opened this issue Dec 12, 2018 · 0 comments
Labels

Comments

@kirrg001
Copy link
Contributor

Background

nql-lang introduced aliases support mid of 2018. nql-lang is able to replace keys in a filter string.

State of NQL 0.2.1

A month a go we added the missing NQL features (e.g. relations, mongo json utility etc.). This is what you have to know:

Aliases are now called: expansions. We no longer use the wording aliases. The reason is that there are two requirements for replacing stuff in a filter:

  1. replace a key name e.g. filter=tags:x -> {tags.slug:x}
  2. expand a statement if a key name matches e.g. filter:primary_tag:de -> {$and: [{tags.slug:de}, {sort_order:0}]} (optional)

That means, the expansions feature is more than just a simple string replacement. It can expand the mongo JSON query.

When the merge json utility logic was moved over from Ghost to NQL, i noticed that we no longer use nql-lang to replace the aliases/expansions. The expansion logic does it now.

Why?

All string filters are parsed by nql-lang as first step. And afterwards we pass the parsed filters into the utility. As soon as a key matches the configured expansions, the expansion logic replaces the key in the mongo json object and adds/extends the expansion filter to the target statement

e.g.

filter=tags:bla+primary_tag:blub

should be

filter=tags.slug:bla+(tags.slug:blub+posts_tags.sort_order:0)

If nql-lang would replace the name independently of the expanded filter, we first would get:

{$and: [tags.slug:bla, tags.slug:blub]}

Now you don't know which part you need to expand?

Discussion/Research

We have not spend further time on this. Is it possible to use nql-lang again?
This needs a bit playing & thinking.

@daniellockyer daniellockyer transferred this issue from TryGhost/NQL-old Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant