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

[FEATURE REQUEST] Support SQL AND and OR operators/mixture of operators #14

Closed
baker-travis opened this issue Jun 2, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@baker-travis
Copy link

This project is awesome and seems like it would drastically simplify the building of our backend filtering/sorting/pagination, but it falls short in a critical area that I have a requirement for. As the title states, I need to be able to support the AND and OR operators, including nesting of operators. Let's say for example I have this structure:

const sampleNoteData = {
  id: '1',
  status: 'open',
  authorId: '313'
}

I want to be able to build a query that looks like this:

const query = {
  filter: {
    _or: {
      id: {
        in: [1, 3]
      },
      _and: {
        status: 'open',
        authorId: '313'
      }
    }
  }
}

Nothing would look much different in the QueryQL class:

class NotesQuerier extends QueryQL {
  defineSchema(schema) {
    schema.filter('id', 'in');
    schema.filter('status', '=');
    schema.filter('authorId', '=');
  }
}

That would result in a knex query like this:

knex('notes').whereIn('id', [1, 3]).orWhere(function() {
  this.where('status', 'open').andWhere('authorId', '313')
});
@jstayton
Copy link
Collaborator

jstayton commented Jun 3, 2020

Hey Travis,

Thanks for the kind words and feature request!

Can you give me more of the background of this requirement for what you're building? Is there a corresponding UI that supports this level of complexity? Or are you using this for queries between services? Or something else completely?

@baker-travis
Copy link
Author

Yes, the UI will support this complex filtering. It will be akin to something like notion.so is doing here:
image

@jstayton
Copy link
Collaborator

jstayton commented Jun 5, 2020

Hey Travis,

I can see how that would be useful, and I can imagine QueryQL supporting something like that if it doesn't add too much complexity. No promise on when I might have time to implement something like that, but I'll keep it in mind for a future version.

Thanks for the suggestion!

@jstayton jstayton closed this as completed Jun 5, 2020
@jstayton jstayton added the enhancement New feature or request label Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants