/** * Gets the query modifiers to apply to this operation. The default is not to apply any modifiers. * * @return the query modifiers, which may be null * @mongodb.driver.manual reference/operator/query-modifier/ Query Modifiers */ DBObject getModifiers() { return options.getModifiers(); }
/** * Informs the database of an indexed field of the collection in order to improve performance. * * @param indexName the name of an index * @return same DBCursor for chaining operations * @mongodb.driver.manual reference/operator/meta/hint/ $hint * @deprecated Prefer {@link #hint(DBObject)} */ @Deprecated public DBCursor hint(final String indexName) { findOptions.getModifiers().put("$hint", indexName); return this; }
/** * Adds a modifier to the find operation * * @param key the modifier name * @param value the modifier value * @return this */ public FindOptions modifier(final String key, final Object value) { options.getModifiers().put(key, value); return this; }
/** * Limits the number of documents a cursor will return for a query. * * @param max the maximum number of documents to return * @return {@code this} so calls can be chained * @mongodb.driver.manual reference/operator/meta/maxScan/ $maxScan * @see #limit(int) * @since 2.12 * @deprecated Deprecated as of MongoDB 4.0 release */ @Deprecated public DBCursor maxScan(final int max) { findOptions.getModifiers().put("$maxScan", max); return this; }
/** * Modifies the documents returned to include references to the on-disk location of each document. The location will be returned in a * property named {@code $diskLoc} * * @return {@code this} so calls can be chained * @mongodb.driver.manual reference/operator/meta/showDiskLoc/ $showDiskLoc * @since 2.12 * @deprecated showDiskLoc has been deprecated in the MongoDB server. There is no replacement for it. */ @Deprecated public DBCursor showDiskLoc() { findOptions.getModifiers().put("$showDiskLoc", true); return this; }
/** * Use snapshot mode for the query. Snapshot mode prevents the cursor from returning a document more than once because an intervening * write operation results in a move of the document. Even in snapshot mode, documents inserted or deleted during the lifetime of the * cursor may or may not be returned. Currently, snapshot mode may not be used with sorting or explicit hints. * * @return {@code this} so calls can be chained * * @see com.mongodb.DBCursor#sort(DBObject) * @see com.mongodb.DBCursor#hint(DBObject) * @mongodb.driver.manual reference/operator/meta/snapshot/ $snapshot * @deprecated Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 release */ @Deprecated public DBCursor snapshot() { findOptions.getModifiers().put("$snapshot", true); return this; }
comment(value.toString()); } else if ("$explain".equals(name)) { findOptions.getModifiers().put("$explain", true); } else if ("$hint".equals(name)) { if (value instanceof String) {
return false; if (dbOptions.getModifiers() != null ? !dbOptions.getModifiers().equals(that.getModifiers()) : that.getModifiers() != null) { return false;
private DBCollectionCountOptions getDbCollectionCountOptions() { DBCollectionCountOptions countOptions = new DBCollectionCountOptions() .readPreference(getReadPreferenceForCursor()) .readConcern(getReadConcern()) .collation(getCollation()) .maxTime(findOptions.getMaxTime(MILLISECONDS), MILLISECONDS); Object hint = findOptions.getHint() != null ? findOptions.getHint() : findOptions.getModifiers().get("$hint"); if (hint != null) { if (hint instanceof String) { countOptions.hintString((String) hint); } else { countOptions.hint((DBObject) hint); } } return countOptions; } }
assertEquals(18, options.getLimit()); assertEquals(new BasicDBObject("i'm a", "modifier") .append("i am", 2), options.getModifiers()); assertEquals(new BasicDBObject("field", "value"), options.getProjection()); assertEquals(15, options.getMaxTime(TimeUnit.MINUTES));
.maxAwaitTime(findOptions.getMaxAwaitTime(MILLISECONDS), MILLISECONDS) .maxTime(findOptions.getMaxTime(MILLISECONDS), MILLISECONDS) .modifiers(collection.wrapAllowNull(findOptions.getModifiers())) .projection(collection.wrapAllowNull(findOptions.getProjection())) .sort(collection.wrapAllowNull(findOptions.getSort()))
/** * Gets the query modifiers to apply to this operation. The default is not to apply any modifiers. * * @return the query modifiers, which may be null * @mongodb.driver.manual reference/operator/query-modifier/ Query Modifiers */ DBObject getModifiers() { return options.getModifiers(); }
/** * Adds a modifier to the find operation * * @param key the modifier name * @param value the modifier value * @return this */ public FindOptions modifier(final String key, final Object value) { options.getModifiers().put(key, value); return this; }
/** * Informs the database of an indexed field of the collection in order to improve performance. * * @param indexName the name of an index * @return same DBCursor for chaining operations * @mongodb.driver.manual reference/operator/meta/hint/ $hint * @deprecated Prefer {@link #hint(DBObject)} */ @Deprecated public DBCursor hint(final String indexName) { findOptions.getModifiers().put("$hint", indexName); return this; }
/** * Modifies the documents returned to include references to the on-disk location of each document. The location will be returned in a * property named {@code $diskLoc} * * @return {@code this} so calls can be chained * @mongodb.driver.manual reference/operator/meta/showDiskLoc/ $showDiskLoc * @since 2.12 * @deprecated showDiskLoc has been deprecated in the MongoDB server. There is no replacement for it. */ @Deprecated public DBCursor showDiskLoc() { findOptions.getModifiers().put("$showDiskLoc", true); return this; }
/** * Limits the number of documents a cursor will return for a query. * * @param max the maximum number of documents to return * @return {@code this} so calls can be chained * @mongodb.driver.manual reference/operator/meta/maxScan/ $maxScan * @see #limit(int) * @since 2.12 * @deprecated Deprecated as of MongoDB 4.0 release */ @Deprecated public DBCursor maxScan(final int max) { findOptions.getModifiers().put("$maxScan", max); return this; }
/** * Use snapshot mode for the query. Snapshot mode prevents the cursor from returning a document more than once because an intervening * write operation results in a move of the document. Even in snapshot mode, documents inserted or deleted during the lifetime of the * cursor may or may not be returned. Currently, snapshot mode may not be used with sorting or explicit hints. * * @return {@code this} so calls can be chained * * @see com.mongodb.DBCursor#sort(DBObject) * @see com.mongodb.DBCursor#hint(DBObject) * @mongodb.driver.manual reference/operator/meta/snapshot/ $snapshot * @deprecated Deprecated in MongoDB 3.6 release and removed in MongoDB 4.0 release */ @Deprecated public DBCursor snapshot() { findOptions.getModifiers().put("$snapshot", true); return this; }
comment(value.toString()); } else if ("$explain".equals(name)) { findOptions.getModifiers().put("$explain", true); } else if ("$hint".equals(name)) { if (value instanceof String) {
private DBCollectionCountOptions getDbCollectionCountOptions() { DBCollectionCountOptions countOptions = new DBCollectionCountOptions() .readPreference(getReadPreferenceForCursor()) .readConcern(getReadConcern()) .collation(getCollation()) .maxTime(findOptions.getMaxTime(MILLISECONDS), MILLISECONDS); Object hint = findOptions.getHint() != null ? findOptions.getHint() : findOptions.getModifiers().get("$hint"); if (hint != null) { if (hint instanceof String) { countOptions.hintString((String) hint); } else { countOptions.hint((DBObject) hint); } } return countOptions; } }
.maxAwaitTime(findOptions.getMaxAwaitTime(MILLISECONDS), MILLISECONDS) .maxTime(findOptions.getMaxTime(MILLISECONDS), MILLISECONDS) .modifiers(collection.wrapAllowNull(findOptions.getModifiers())) .projection(collection.wrapAllowNull(findOptions.getProjection())) .sort(collection.wrapAllowNull(findOptions.getSort()))