Filter KeystoneJS relationship by id Filter KeystoneJS relationship by id mongoose mongoose

Filter KeystoneJS relationship by id


Ignacio, as I mentioned in my comment earlier, as of this writing, Keystone did not provide he ability to filter relationships by the current model's id. However, inspired by your question, I decided to submit a pull request (PR #609) adding this feature to Keystone.

The new feature will work exactly as you expected. In your use case the code would be:

  jury: {    winner: {      type: Types.Relationship,      ref: 'Entry',      many: false,      filters: {        'contest.id': ':_id',   /* <--- filter */        'contest.state': 'admited'      }    }  }

I will post another comment here once the PR is merged. #609 also includes documentation for the relationship filters feature in general so, once merged, the documentation will be included in the Keystone website after the next build.