Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
Spring data mongodb remove a property from a document using MongoTemplate

I have a document as shown below

{
    "_id" : ObjectId("5864ddd8e38112fd70b89893"),
    "_class" : "com.apic.models.UserReg",
    "name" : "xxx",
    "email" : "xxx.xxx@xxx.com"
    "activationToken" : "fe8376ea2dbdf61ebc"
}

How can I remove the property activationToken from it using Spring MongoTemplate?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The following example removes the property activationToken from documents with the email xxx.xxx@xxx.com using the $unset update modifier:

Query query = new Query();
query.addCriteria(Criteria.where("email").is("xxx.xxx@xxx.com"));
Update update = new Update();
update.unset("activationToken");

// run update operation
mongoTemplate.updateMulti(query, update, User.class);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!