I have a document as shown below
{
"_id" : ObjectId("5864ddd8e38112fd70b89893"),
"_class" : "com.apic.models.UserReg",
"name" : "xxx",
"email" : "[email protected]"
"activationToken" : "fe8376ea2dbdf61ebc"
}
How can I remove the property activationToken
from it using Spring MongoTemplate
?
The following example removes the property activationToken
from documents with the email [email protected]
using the $unset
update modifier:
Query query = new Query();
query.addCriteria(Criteria.where("email").is("[email protected]"));
Update update = new Update();
update.unset("activationToken");
// run update operation
mongoTemplate.updateMulti(query, update, User.class);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With