public Optional<ContentPack> findByIdAndRevision(ModelId id, int revision) { final DBQuery.Query query = DBQuery.is(Identified.FIELD_META_ID, id).is(Revisioned.FIELD_META_REVISION, revision); return Optional.ofNullable(dbCollection.findOne(query)); }
@Override protected Query put(String field, String op, QueryCondition value) { Query subQuery; QueryCondition saved = query.get(field); if (!(saved instanceof CompoundQueryCondition)) { subQuery = new Query(); boolean targetIsCollection = (value instanceof CollectionQueryCondition && ((CollectionQueryCondition)value).targetIsCollection()) || (value instanceof CompoundQueryCondition && ((CompoundQueryCondition)value).targetIsCollection()); query.put(field, new CompoundQueryCondition(subQuery, targetIsCollection)); } else { subQuery = ((CompoundQueryCondition) saved).getQuery(); } subQuery.put(op, value); return this; }
public QuoteReadModel findByExchangeAndTicker(String exchangeId, String tickerSymbol) { return entitiesCollection.findOne(DBQuery.is("exchangeId", exchangeId).and(DBQuery.is("ticker", tickerSymbol))); }
private DBQuery.Query withExchangeIdAndTickerSymbol(String exchangeId, String tickerSymbol) { return DBQuery.is("exchangeId", exchangeId).and(DBQuery.is("currencyPairId", tickerSymbol)); } }
/** * The field, modulo the given mod argument, is equal to the value * * @param field * The field to compare * @param mod * The modulo * @param value * The value to compare to * @return the query */ public static Query mod(String field, Number mod, Number value) { return new Query().mod(field, mod, value); }
public ConfigurationBundle findByNameAndCategory(final String name, final String category) { final DBQuery.Query query = DBQuery.is("name", name).is("category", category); return dbCollection.findOne(query); }
/** * An element in the given array field matches the given query * * @param field * the array field * @param query * The query to attempt to match against the elements of the * array field * @return the query */ public static Query elemMatch(String field, Query query) { return new Query().elemMatch(field, query); }
/** * The field is less than or equal to the given value * * @param field * The field to compare * @param value * The value to compare to * @return the query */ public static Query lessThanEquals(String field, Object value) { return new Query().lessThanEquals(field, value); }
/** * Create an empty query * * @return The empty query */ public static Query empty() { return new Query(); }
private static Document serializeQuery( SerializerProvider serializerProvider, JsonSerializer<?> serializer, DBQuery.Query query) { Document serializedQuery = new Document(); for (Map.Entry<String, QueryCondition> field : query.conditions()) { String key = field.getKey(); QueryCondition condition = field.getValue(); serializedQuery.put( key, serializeQueryCondition(serializerProvider, serializer, key, condition)); } return serializedQuery; }
private static DBObject serializeQuery( SerializerProvider serializerProvider, JsonSerializer<?> serializer, DBQuery.Query query) { DBObject serializedQuery = new BasicDBObject(); for (Map.Entry<String, QueryCondition> field : query.conditions()) { String key = field.getKey(); QueryCondition condition = field.getValue(); serializedQuery.put( key, serializeQueryCondition(serializerProvider, serializer, key, condition)); } return serializedQuery; }
/** * The field is greater than the given value * * @param field * The field to compare * @param value * The value to compare to * @return the query */ public static Query greaterThan(String field, Object value) { return new Query().greaterThan(field, value); }