本文整理了Java中com.mongodb.client.model.Updates.pullAll()
方法的一些代码示例,展示了Updates.pullAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Updates.pullAll()
方法的具体详情如下:
包路径:com.mongodb.client.model.Updates
类名称:Updates
方法名:pullAll
[英]Creates an update that removes all instances of the given values from the array value of the field with the given name.
[中]创建一个更新,从具有给定名称的字段的数组值中删除给定值的所有实例。
代码示例来源:origin: opencb/opencga
public MongoDBVariantMergeLoader(MongoDBCollection variantsCollection, MongoDBCollection stageCollection,
MongoDBCollection studiesCollection, StudyConfiguration studyConfiguration, List<Integer> fileIds,
boolean resume, boolean cleanWhileLoading, ProgressLogger progressLogger) {
this.progressLogger = progressLogger;
this.variantsCollection = variantsCollection;
this.stageCollection = stageCollection;
this.studiesCollection = studiesCollection;
this.resume = resume;
this.studyId = studyConfiguration.getStudyId();
this.fileIds = fileIds;
this.result = new MongoDBVariantWriteResult();
result.getGenotypes().addAll(studyConfiguration.getAttributes().getAsStringList(LOADED_GENOTYPES.key()));
this.cleanWhileLoading = cleanWhileLoading;
List<String> studyFileToPull = new ArrayList<>(fileIds.size());
for (Integer fileId : fileIds) {
studyFileToPull.add(studyId + "_" + fileId);
}
List<Bson> cleanStageDuplicatedList = new ArrayList<>(fileIds.size() + 1);
for (Integer fileId : fileIds) {
// Can not unset value!
cleanStageDuplicatedList.add(set(studyId + "." + fileId, null));
}
cleanStageDuplicatedList.add(pullAll(StageDocumentToVariantConverter.STUDY_FILE_FIELD, studyFileToPull));
List<Bson> cleanStageList = new ArrayList<>(cleanStageDuplicatedList.size() + 1);
cleanStageList.addAll(cleanStageDuplicatedList);
cleanStageList.add(set(studyId.toString() + '.' + NEW_STUDY_FIELD, false));
cleanStageDuplicated = combine(cleanStageDuplicatedList);
cleanStage = combine(cleanStageList);
}
代码示例来源:origin: opencb/opencga
@Override
public void removeUsersFromAllGroups(long studyId, List<String> users) throws CatalogDBException {
if (users == null || users.size() == 0) {
throw new CatalogDBException("Unable to remove users from groups. List of users is empty");
}
Document query = new Document()
.append(PRIVATE_UID, studyId)
.append(QueryParams.GROUP_USER_IDS.key(), new Document("$in", users))
.append("$isolated", 1);
Bson pull = Updates.pullAll("groups.$.userIds", users);
// Pull those users while they are still there
QueryResult<UpdateResult> update;
do {
update = studyCollection.update(query, pull, null);
} while (update.first().getModifiedCount() > 0);
}
代码示例来源:origin: opencb/opencga
@Override
public void removeUsersFromGroup(long studyId, String groupId, List<String> members) throws CatalogDBException {
if (members == null || members.size() == 0) {
throw new CatalogDBException("Unable to remove members from group. List of members is empty");
}
Document query = new Document()
.append(PRIVATE_UID, studyId)
.append(QueryParams.GROUP_NAME.key(), groupId)
.append("$isolated", 1);
Bson pull = Updates.pullAll("groups.$.userIds", members);
QueryResult<UpdateResult> update = studyCollection.update(query, pull, null);
if (update.first().getMatchedCount() != 1) {
throw new CatalogDBException("Unable to remove members from group " + groupId + ". The group does not exist.");
}
}
代码示例来源:origin: opencb/opencga
updates.add(pullAll(StageDocumentToVariantConverter.STUDY_FILE_FIELD, studyFiles));
Bson filter = and(in(StageDocumentToVariantConverter.STUDY_FILE_FIELD, studyFiles), chrFilter, and(filters));
LOGGER.info("Clean studies from stage where all the files where duplicated");
updates.add(pullAll(StageDocumentToVariantConverter.STUDY_FILE_FIELD, studyFiles));
LOGGER.info("Cleaning files {} from stage collection", fileIds);
modifiedCount += stageCollection.update(and(filters), combine(updates),
内容来源于网络,如有侵权,请联系作者删除!