Created
September 26, 2021 07:17
-
-
Save alex-ber/53325b24bfac9b39920835140ab10d70 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mkyong.domain; | |
import com.mongodb.WriteResult; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.data.mongodb.core.MongoTemplate; | |
import org.springframework.data.mongodb.core.query.Criteria; | |
import org.springframework.data.mongodb.core.query.Query; | |
import org.springframework.data.mongodb.core.query.Update; | |
//Impl postfix of the name on it compared to the core repository interface | |
public class DomainRepositoryImpl implements DomainRepositoryCustomAnyName { | |
@Autowired | |
MongoTemplate mongoTemplate; | |
@Override | |
public int updateDomainDisplayFlagOnly(String domain, boolean flag) { | |
Query query = new Query(Criteria.where("domain").is(domain)); | |
Update update = new Update(); | |
update.set("display", flag); | |
WriteResult result = mongoTemplate.updateFirst(query, update, Domain.class); | |
if(result!=null) | |
return result.getN(); | |
else | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment