wso2wso2-integration-studio

Error 'unknown MongoDB operation 'aggregate'' when using aggregate in WSo2 Integration Studio?


I am working Wso2 Integration Studio 8.1 version. I want to using aggregate query. But Wso2 Integration Studip giving error as DS Fault Message: Error in MongoQuery.runQuery: DS Fault Message: Unknown MongoDB operation 'aggregate'


Solution

  • I'm afraid it seems the Micro Integrator doesn't support it at the moment. This is from the code which supports the following operations.

    private DBConstants.MongoDB.MongoOperation convertToMongoOp(String operation) throws DataServiceFault {
            if (DBConstants.MongoDB.MongoOperationLabels.COUNT.equals(operation)) {
                return DBConstants.MongoDB.MongoOperation.COUNT;
            } else if (DBConstants.MongoDB.MongoOperationLabels.DROP.equals(operation)) {
                return DBConstants.MongoDB.MongoOperation.DROP;
            } else if (DBConstants.MongoDB.MongoOperationLabels.FIND.equals(operation)) {
                return DBConstants.MongoDB.MongoOperation.FIND;
            } else if (DBConstants.MongoDB.MongoOperationLabels.FIND_ONE.equals(operation)) {
                return DBConstants.MongoDB.MongoOperation.FIND_ONE;
            } else if (DBConstants.MongoDB.MongoOperationLabels.INSERT.equals(operation)) {
                return DBConstants.MongoDB.MongoOperation.INSERT;
            } else if (DBConstants.MongoDB.MongoOperationLabels.REMOVE.equals(operation)) {
                return DBConstants.MongoDB.MongoOperation.REMOVE;
            } else if (DBConstants.MongoDB.MongoOperationLabels.UPDATE.equals(operation)) {
                return DBConstants.MongoDB.MongoOperation.UPDATE;
            } else if (DBConstants.MongoDB.MongoOperationLabels.EXISTS.equals(operation)) {
                return DBConstants.MongoDB.MongoOperation.EXISTS;
            }  else if (DBConstants.MongoDB.MongoOperationLabels.CREATE.equals(operation)) {
                return DBConstants.MongoDB.MongoOperation.CREATE;
            } else {
                throw new DataServiceFault("Unknown MongoDB operation '" + operation + "'");
            }
        }
    

    Even the MongoDB connector doesn't support Aggregate operation, hence your best option is to write a Custom mediator to get this done or try to improve the existing connector.