MongoDB
 sql >> Base de Dados >  >> NoSQL >> MongoDB

Como suprimir uma coluna no mongodb usando drivers Java?


Você pode tentar algo assim.
import static com.mongodb.client.model.Projections.excludeId;

FindIterable<Document> resultSet = db.getCollection("document").find(query).projection(excludeId());

Excluir outros campos
import static com.mongodb.client.model.Projections.fields;

FindIterable<Document> resultSet = db.getCollection("document").find(query).projection(
fields(exclude("fieldname", "fieldvalue")));

Para lista completa de projeções.

http://api.mongodb.com/ java/3.0/?com/mongodb/client/model/Projections.html http://mongodb.github.io/mongo-java- driver/3.0/builders/projections/