chore: Remove unused updateByIdAndFieldNames method (#29237)

This commit is contained in:
Shrikant Sharat Kandula 2023-11-30 16:19:00 +05:30 committed by GitHub
parent eb4d4f3f82
commit a8f7b4b081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 31 deletions

View File

@ -1,6 +1,5 @@
package com.appsmith.server.repositories;
import com.mongodb.client.result.UpdateResult;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.data.repository.NoRepositoryBean;
import reactor.core.publisher.Mono;
@ -8,7 +7,6 @@ import reactor.core.publisher.Mono;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@NoRepositoryBean
public interface BaseRepository<T, ID extends Serializable> extends ReactiveMongoRepository<T, ID> {
@ -53,9 +51,4 @@ public interface BaseRepository<T, ID extends Serializable> extends ReactiveMong
* against the `fieldNames` property in the matching object.
*/
Mono<T> findByIdAndFieldNames(ID id, List<String> fieldNames);
/**
* This method is supposed to update the given list of fields in an object as opposed to replacing the entire object.
*/
Mono<UpdateResult> updateByIdAndFieldNames(ID id, Map<String, Object> fieldNameValueMap);
}

View File

@ -2,8 +2,6 @@ package com.appsmith.server.repositories;
import com.appsmith.external.models.BaseDomain;
import com.appsmith.server.constants.FieldName;
import com.mongodb.client.result.UpdateResult;
import jakarta.validation.constraints.NotNull;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Example;
@ -23,7 +21,6 @@ import java.io.Serializable;
import java.time.Instant;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.springframework.data.mongodb.core.query.Criteria.where;
@ -144,27 +141,6 @@ public class BaseRepositoryImpl<T extends BaseDomain, ID extends Serializable>
return this.findById(id);
}
/**
* This method is supposed to update the given list of field names with the associated values in an object as opposed to replacing the entire object.
*/
@Override
public Mono<UpdateResult> updateByIdAndFieldNames(@NotNull ID id, @NotNull Map<String, Object> fieldNameValueMap) {
return ReactiveSecurityContextHolder.getContext()
.map(ctx -> ctx.getAuthentication())
.map(auth -> auth.getPrincipal())
.flatMap(principal -> {
Query query = new Query(getIdCriteria(id));
query.addCriteria(notDeleted());
Update update = new Update();
fieldNameValueMap.forEach((fieldName, fieldValue) -> {
update.set(fieldName, fieldValue);
});
return mongoOperations.updateFirst(query, update, entityInformation.getJavaType());
});
}
@Override
public Flux<T> findAll() {
return ReactiveSecurityContextHolder.getContext()