當前位置: 首頁>>代碼示例>>Java>>正文


Java Update.pull方法代碼示例

本文整理匯總了Java中org.springframework.data.mongodb.core.query.Update.pull方法的典型用法代碼示例。如果您正苦於以下問題:Java Update.pull方法的具體用法?Java Update.pull怎麽用?Java Update.pull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.data.mongodb.core.query.Update的用法示例。


在下文中一共展示了Update.pull方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: removeFavor

import org.springframework.data.mongodb.core.query.Update; //導入方法依賴的package包/類
@Override
public void removeFavor(long colId, String uid) {
    Query query = new Query();
    query.addCriteria(
        Criteria.where("collectionId").is(colId).and("favors").elemMatch(Criteria.where("uid").is(uid)));

    Update update = new Update();
    //update.unset("dataList.$");
    //mMongoTemplate.upsert(query, update, Favor.class);
    // http://stackoverflow.com/questions/35600557/mongodb-how-using-spring-cryteria-remove-element-from-nested-object-array
    // http://ufasoli.blogspot.fr/2012/09/mongodb-spring-data-remove-elements.html?view=sidebar
    update.pull("favors", new BasicDBObject("uid", uid));
    mMongoTemplate.updateMulti(query, update, CollectionBinding.class);
}
 
開發者ID:TomeOkin,項目名稱:LsPush-Server,代碼行數:15,代碼來源:CollectionBindingRepositoryImpl.java

示例2: buildPullObject

import org.springframework.data.mongodb.core.query.Update; //導入方法依賴的package包/類
private DBObject buildPullObject(List<Entity> subEntities) {
    Set<String> existingIds = new HashSet<String>(getSubDocDids(subEntities));
    Query pullQuery = new Query(Criteria.where("_id").in(existingIds));
    Update update = new Update();
    update.pull(subField, pullQuery.getQueryObject());
    return update.getUpdateObject();
}
 
開發者ID:inbloom,項目名稱:secure-data-service,代碼行數:8,代碼來源:SubDocAccessor.java

示例3: buildPullObject

import org.springframework.data.mongodb.core.query.Update; //導入方法依賴的package包/類
private DBObject buildPullObject(List<Entity> entities) {
    Query pullQuery = new Query();

    List <Criteria> orList = new ArrayList<Criteria>();
    for (Entity entity : entities) {
        String internalId = null;
        if (denormalizedIdKey.equals("_id")) {
            internalId = entity.getEntityId();
        } else {
            internalId = (String) entity.getBody().get(denormalizedIdKey);
        }
        //delete studentSectionAssociation DND where (sectionId(_id) = "x1" and beginDate(denormalizedKey) = "y1") OR (sectionId(_id) = "x2" and beginDate(denormalizedKey) = "y2") ...
        //delete studentSchoolAssociation  DND where (schoolld(_id)  = "x1" and entryDate(denormalizedKey) = "y1") OR (schoolld(_id)  = "x2" and entryDate(denormalizedKey) = "y2") ...
        //DND -> denormalizedDoc
        List<Criteria> andList = new ArrayList<Criteria>();
        andList.add(Criteria.where("_id").is(internalId));
        for(String denormalizedKey:denormalizedEntityKeys) {
            String denormalizedValue = (String) entity.getBody().get(denormalizedKey);
            andList.add( Criteria.where(denormalizedKey).is(denormalizedValue));
        }
            Criteria and = new Criteria().andOperator(andList.toArray(new Criteria[0]));
            orList.add(and);
    }
    Criteria or = new Criteria().orOperator(orList.toArray(new Criteria[0]));
    pullQuery.addCriteria(or);

    Update update = new Update();
    update.pull(denormalizedToField, pullQuery.getQueryObject());

    return update.getUpdateObject();
}
 
開發者ID:inbloom,項目名稱:secure-data-service,代碼行數:32,代碼來源:Denormalizer.java


注:本文中的org.springframework.data.mongodb.core.query.Update.pull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。