All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mongodb.MongoView Maven / Gradle / Ivy

Go to download

An extension to the MongoDB Java Driver library that goes beyond what the GridFS feature supports. Compressed file storage, zip files, temporary files

There is a newer version: 0.10.0
Show newest version
package org.mongodb;

import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.WriteConcern;

public class MongoView {

    private DBCursor surrogate;
    private WriteConcern writeConcern;

    public MongoView(final DBCursor cursor) {
        this.surrogate = cursor;
    }

    public MongoView(final DBCursor cursor, final WriteConcern writeConcern) {
        this.surrogate = cursor;
    }

    public MongoCursor get() {
        return new MongoQueryCursor(surrogate);
    }

    public T getOne() {
        return get().next();
    }

    public MongoView sort(final Document sort) {
        surrogate = surrogate.sort(sort.getSurrogate());
        return this;
    }

    public MongoView withWriteConcern(final WriteConcern writeConcern) {
        this.writeConcern = writeConcern;
        return this;
    }

    public void update(final Document updateQuery) {
        DBObject query = surrogate.getQuery();
        surrogate.getCollection().update(query, updateQuery.getSurrogate(), false, true, writeConcern);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy