public static Bson getProjection(QueryOptions options) { Bson projection = getProjection(null, options); return projection != null ? Aggregates.project(projection) : null; }
public static void parseQueryOptions(List<Bson> operations, QueryOptions options) { if (options != null) { Bson projection = getProjection(options); if (projection != null) { operations.add(projection); } Bson skip = getSkip(options); if (skip != null) { operations.add(skip); } Bson limit = getLimit(options); if (limit != null) { operations.add(limit); } Bson sort = getSort(options); if (sort != null) { operations.add(sort); } } }
public Document findAndUpdate(Bson query, Bson projection, Bson sort, Bson update, QueryOptions options) { boolean upsert = false; boolean returnNew = false; if (options != null) { if (projection == null) { projection = getProjection(projection, options); } upsert = options.getBoolean("upsert", false); returnNew = options.getBoolean("returnNew", false); } FindOneAndUpdateOptions findOneAndUpdateOptions = new FindOneAndUpdateOptions() .sort(sort) .projection(projection) .upsert(upsert) .returnDocument(returnNew ? ReturnDocument.AFTER : ReturnDocument.BEFORE); return dbCollection.findOneAndUpdate(query, update, findOneAndUpdateOptions); }
public FindIterable<Document> find(Bson query, Bson projection, QueryOptions options) { projection = getProjection(projection, options);
projection = getProjection(projection, options);