Can we use spring data repository to update embedded documents in mongodb
{
"_id" : 1000,
"user_id" : "001",
"events" : [
{
"handled" : 1,
"profile" : 10,
"data" : "....."
}
{
"handled" : 1,
"profile" : 10,
"data" : "....."
}
{
"handled" : 1,
"profile" : 20,
"data" : "....."
}
...
]
}
I want to update the handle to 10 where events.profile is 10. I know how to do it using mongoTemplate but i need to know how to do it using mongoRepository. Thanks
As far as I understand you want to create a Repository with an update-Method? During my resarch in the spring-data reference i couldnt find any hint, that this is supported by spring data.
So in your case you could create a query like 'Collection findByEvents_Profile(Integer id)', iterate over the collection and persist it again by calling the repositories 'saveAll' method.