Skip to content
This repository was archived by the owner on Mar 1, 2022. It is now read-only.

Filter by multiple relation columns #14

Closed
2 tasks done
kirrg001 opened this issue Nov 14, 2018 · 1 comment · Fixed by #15
Closed
2 tasks done

Filter by multiple relation columns #14

kirrg001 opened this issue Nov 14, 2018 · 1 comment · Fixed by #15
Assignees
Labels

Comments

@kirrg001
Copy link
Contributor

kirrg001 commented Nov 14, 2018

CASE 1

{
  $and: [
                    {
                        'tags.slug': 'animal'
                    },
                    {
                        'posts_tags.sort_order': 0
                    }
   ]
};

"Filter all posts which are tagged with animal and it's the first tag"

This case is important.

CASE 2

{
  $and: [
                    {
                        'tags.slug': 'animal'
                    },
                    {
                        'tags.title': 'something'
                    }
   ]
};

"Filter all posts which are tagged with animal and the tag title is something".

This case is less important.

CASE 3 (combination)

{
  $and: [
    $and: [
                    {
                        'tags.slug': 'animal'
                    },
                    {
                        'tags.title': 'something'
                    }
     },
     {
        featured: true
     }
   ]
};

"Filter all posts which are tagged with animal and the tag title is something".

This case is important.

Known Problems

The architecture must order where statements which belong together.

Futhermore: posts_tags is the many-to-many lookup table of posts and tags. If you pass posts_tags.sort_order, we first check if the table name is a relation, if not, we check if the table name is a join table. I think this could work.

Tasks

  • play with the cases
  • implement
@kirrg001 kirrg001 self-assigned this Nov 14, 2018
kirrg001 added a commit to kirrg001/mongo-knex that referenced this issue Nov 14, 2018
kirrg001 added a commit to kirrg001/mongo-knex that referenced this issue Nov 15, 2018
closes TryGhost#14

- the code becomes a little hard to read, but i'd not refactor it till we have all cases in place
@kirrg001
Copy link
Contributor Author

We can open a new issue if there are more cases.

kirrg001 added a commit that referenced this issue Nov 15, 2018
closes #14

- the code becomes a little hard to read, but i'd not refactor it till we have all cases in place
- this commit supports the cases listed in #14 
- i've raised #17 to refactor the converter.js
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant