I am new to Spring-data, so pardon me if my question is to naive
I am trying to query the document which looks like this:
{
_id: 1,
name: "sue",
age: 19,
type: 1,
status: "P",
favorites: { artist: "Picasso", food: "pizza" },
finished: [ 17, 3 ],
badges: [ "blue", "black" ],
points: [
{ points: 85, bonus: 20 },
{ points: 85, bonus: 10 }
]
}
I wanted to do the query which gives me the list of the entries which contains the favourites.artist="Picasso"
.
I know how to do this using the MongoTemplate
I wanted to do that using MongoRepository
.
I was reading some document which shows query like this
findByFavorites(Favorites favorites)
but I couldn't find anything with which I can query using the field of the embedded document.
It should be
findByFavoritesArtist(@Param("favorites.artist") String artist);
So you just concatenate together the names of the properties in the property path in our embedded object. It is possible that the above query is redundant and you can leave out the @Param annotation.