Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,8 @@ private AggregateIterable<Document> getAggregateIterable(Map<String, Object> exe
ExecuteObject executeObject = new ExecuteObject(executeObj);
String database = executeObject.getDatabase();
String collection = executeObject.getCollection();
if (collection == null || collection.isEmpty()) {
throw new RuntimeException(String.format("Process execute %s failed, collection name cannot be blank", executeObject));
}
List<Document> pipelines = executeObject.getPipeline();
if (pipelines.isEmpty()) {
if (pipelines == null || pipelines.isEmpty()) {
throw new RuntimeException(String.format("Process execute %s failed, pipeline cannot be blank", executeObject));
}
boolean allowDiskUse = true;
Expand All @@ -189,7 +186,11 @@ private AggregateIterable<Document> getAggregateIterable(Map<String, Object> exe
// ignored
}

return mongoClient.getDatabase(database).getCollection(collection).aggregate(pipelines).allowDiskUse(allowDiskUse);
MongoDatabase mongoDatabase = mongoClient.getDatabase(database);
if (collection == null || collection.isEmpty()) {
return mongoDatabase.aggregate(pipelines).allowDiskUse(allowDiskUse);
}
return mongoDatabase.getCollection(collection).aggregate(pipelines).allowDiskUse(allowDiskUse);
}

public Object aggregate(Map<String, Object> executeObj, MongoClient mongoClient) {
Expand Down