I was finding on the internet how to update all the document field values with lowercase. I luckily found a query which I modified as per my requirement and it is working correctly.
db.messages.updateMany({},
[
{
$set: {
recipientEmail: {
$toLower: '$recipientEmail'
},
senderEmail: {
$toLower: '$senderEmail'
}
}
}
],{ multi: true })
But now I am trying to convert this query into Java code, I am not able to convert it. I again started looking into the internet, but couldn’t find any code. So, can anyone help me convert this query to Java code so that I can use it in my Spring Boot application? Thanks in advance.
You can use @Query annotation in your repository interface and pass your query as it is (above the method signature). Here is an example :