MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Come sopprimere una colonna in mongodb usando i driver Java?

Puoi provare qualcosa del genere.

import static com.mongodb.client.model.Projections.excludeId;

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

Escludi altri campi

import static com.mongodb.client.model.Projections.fields;

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

Per l'elenco completo delle proiezioni.

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