java中mongodb添加查询条件,很简单
解决方法:
查询taskTime>=123456 和action不等于1的数据,查询条件如下所示:
Bson filter = Filters.and(Filters.lte("taskTime", "123456"), Filters.ne("action", 1));
try (MongoCursor<Document> cursor = collection.find(filter).iterator()) {
if (cursor.hasNext()) {
Document taskDoc = cursor.next();
}
}