src/main/java/org/mongojack/JacksonMongoCollection.java
/**
     * Finds the first document in the query and updates it.
     * 
     * @param query
     *            query to match
     * @param fields
     *            fields to be returned
     * @param sort
     *            sort to apply before picking first document
     * @param update
     *            update to apply
     * @param returnNew
     *            if true, the updated document is returned, otherwise the old
     *            document is returned (or it would be lost forever)
     * @param upsert
     *            do upsert (insert if document not present)
     * @return the object
     */
Finds the first document in the query and updates it.


Finds the first document in the query and updates it .
public T findAndModify(DBQuery.Query query, Document fields, Document sort, DBUpdate.Builder update, boolean returnNew, boolean upsert) {
        return mongoCollection.findOneAndUpdate(serializeQuery(query), update.serializeAndGetAsDocument(objectMapper, type),
                new FindOneAndUpdateOptions().returnDocument(
                        returnNew
                                ? ReturnDocument.AFTER
                                : ReturnDocument.BEFORE).projection(fields).sort(sort).upsert(upsert));
    }
public T findAndModify ( DBQuery . Query query , Document fields , Document sort , DBUpdate . Builder update , boolean returnNew , boolean upsert ) { return mongoCollection . findOneAndUpdate ( serializeQuery ( query ) , update . serializeAndGetAsDocument ( objectMapper , type ) , new FindOneAndUpdateOptions ( ) . returnDocument ( returnNew ? ReturnDocument . AFTER : ReturnDocument . BEFORE ) . projection ( fields ) . sort ( sort ) . upsert ( upsert ) ) ; }
Finds the first document in the query and updates it.
Finds the first document in the query and updates it .