org.mongodb.MongoView Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mongoFS Show documentation
Show all versions of mongoFS Show documentation
An extension to the MongoDB Java Driver library that goes beyond what the GridFS feature supports.
Compressed file storage, zip files, temporary files
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