spring-projects / spring-projects/spring-data-mongodb

Add static method to create OR criterion.

Open
#3,884 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Currently the only way to create an $or only query is counter intuitive and leads people to creating $and combined criterions to a single element $or as outlined below.

query(where("title").is(...).orOperator(where("content").is(...))
{
  "title": ...,
  "$or": [
    {
      "content": ...
    }
  ]
}

The correct, rather cumbersome usage would be as follows:

query(new Criteria().orOperator(where("title").is(...), where("content").is(...)))

Introducing a static or(Critieria... criterions) method would allow for simpler usage

query(or(where("title").is(...), where("content").is(...)))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Criteria class and its existing orOperator API, then review nearby tests for criteria construction. Done means the requested static or(Criteria... criterions) entry point supports the simpler query form shown in the issue and is covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mongodb
Domain
backend, database
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.