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

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5f850-45844.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5f850-45844.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?