MongoRepository update field

when using MongoRepository, I found that I want to update a field, but MongoRepository only provides the save method, but the save method requires a primary key. I directly use the default _ id as the primary key, and use the save method to insert a piece of data directly. Is there any other way to update the field? I don"t know whether it is possible to use the annotation @ Query method

.
Sep.17,2021

The save method in

MongoRepository detects whether it exists or not. If it doesn't exist, it's insert, and the same thing is update.
if you're using Spring Data MongoDB

.
 mongoTemplate.upsert(newQuery(Criteria.where("name").is("AAA")), newUpdate().set("name", "BBB"), collectionName); 

$set learn about

Menu