Skip to content

Aliases/expansions research #8

Description

@kirrg001

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions