org.mongodb.MongoCollection 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.DBCollection;
import com.mongodb.DBObject;
public class MongoCollection {
private DBCollection surrogate;
public MongoCollection(final DBCollection db) {
this.surrogate = db;
}
public void save(final Document document) {
DBObject dbObject = document.getSurrogate();
Object id = dbObject.get("_id");
if (id == null) {
surrogate.insert(dbObject);
}
else {
surrogate.save(dbObject);
}
}
public String getName() {
return surrogate.getName();
}
public MongoDatabase getDatabase() {
return new MongoDatabase(surrogate.getDB());
}
public MongoView find(final Document in) {
return new MongoView(surrogate.find(in.getSurrogate()));
}
public CollectionAdministration tools() {
return new CollectionAdministration(surrogate);
}
public WriteResult remove(final Document filesQuery) {
return new WriteResult(surrogate.remove(filesQuery.getSurrogate()));
}
public void createIndex(final Document document) {
surrogate.createIndex(document.getSurrogate());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy