Example usage for com.mongodb BasicDBObject containsField

List of usage examples for com.mongodb BasicDBObject containsField

Introduction

In this page you can find the example usage for com.mongodb BasicDBObject containsField.

Prototype

public boolean containsField(final String field) 

Source Link

Document

Checks if this object contains a given field

Usage

From source file:uk.co.revsys.oddball.rules.MongoDBHelper.java

private void addCaseBeforeQuery(BasicDBObject query, String before) {
    long cutoff = 0;
    try {//  ww w  .ja va  2  s  .c  o  m
        cutoff = Long.parseLong(before);
    } catch (java.lang.NumberFormatException e) {
    }
    BasicDBObject subQuery = new BasicDBObject("$lt", cutoff);
    if (query.containsField("case.time")) {
        ((BasicDBObject) query.get("case.time")).append("$lt", cutoff);
    } else {
        query.append("case.time", subQuery);
    }
}