spring-projects / spring-data-mongodb

Provides support to increase developer productivity in Java when using MongoDB. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-mongodb/
Apache License 2.0
1.62k stars 1.09k forks source link

Support For Named Json Queries In Spring Data MongoDB [DATAMONGO-2013] #2882

Closed spring-projects-issues closed 10 months ago

spring-projects-issues commented 6 years ago

Ankur Pathak opened DATAMONGO-2013 and commented

We should store our mongo db queries in json something like below: 

{ "filters" : { "User.username" : { "username" : "?1" } },

"sorts": { "User.username" :{ "username" : -1 }

},

"projections" : { "User.username" : { "firstName": true, "lastName" : true, "_id": false

}

},

"aggregations": {

}

}

 And then use them in repositories like below:

interface IUserRepository extends MongoRepository<User, Long> {

@NamedQuery(sort = "User.username", filter: "User.username", projetion: "User.username") Page\ findByUsername(Pageable pageable); }

This will separate the queries(strings) and repository(java) separate. It will also make queries easier to write. The queries will look elegant and natural as they are used in mongodb


No further details from DATAMONGO-2013

christophstrobl commented 10 months ago

Closing this one as we're not adding yet another way to express queries.