Example usage for org.springframework.data.mongodb.core.query Update pull

List of usage examples for org.springframework.data.mongodb.core.query Update pull

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.query Update pull.

Prototype

public Update pull(String key, Object value) 

Source Link

Document

Update using the $pull update modifier

Usage

From source file:quanlyhocvu.api.mongodb.DAO.LopHocDAO.java

public boolean deleteHocSinh(String classId, String studentIds) {
    boolean res = true;

    Query query = Query.query(Criteria.where("id").is(classId));
    Update update = new Update();
    update.pull("listIDHocSinh", studentIds);

    mongoOperation.findAndModify(query, update, LopHocDTO.class);

    return res;/* w w w. j ava2  s  .c  o m*/
}

From source file:org.ow2.play.metadata.service.MetadataServiceImpl.java

@Override
@WebMethod// w w  w. j  ava2s .  com
public void removeMetadata(Resource resource, Metadata metadata) throws MetadataException {
    Update update = new Update();
    update.pull("metadata", metadata);
    mongoTemplate.updateFirst(
            query(where("resource.name").is(resource.getName()).and("resource.url").is(resource.getUrl())),
            update, org.ow2.play.metadata.service.document.MetaResource.class);
}

From source file:app.data.local.CollectionBindingRepositoryImpl.java

@Override
public void removeFavor(long colId, String uid) {
    Query query = new Query();
    query.addCriteria(/*ww w  .j  a va2s.  c o  m*/
            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);
}