Skip to content

Allow for equality queries with respect to arrays or primitives [DATAMONGO-1897] #2766

Open
@spring-projects-issues

Description

@spring-projects-issues

Rafal Glowinski opened DATAMONGO-1897 and commented

Having a simple MongoDB document that contains an array:

{ 
    "type": "SOME_TYPE",
    "permissions" : ["A", "B", "C"]
}

I would like to find all documents that match this MongoDB query:

{ "type": "SOME_TYPE", "permissions": { $elemMatch: { $eq: "B" } } }

Currently, I have to use this construct:

Criteria.where("type").is("SOME_TYPE").and("permissions").elemMatch(new Criteria().in("B"))

which translates to:

{ "type": "SOME_TYPE", "permissions": { $in: ["B"] } }

What is missing, in my opinion, is a method 'eq' on Criteria, that would let us write:

Criteria.where("type").is("SOME_TYPE").and("permissions").elemMatch(new Criteria().eq("B"))

Attachments:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions