Can I intercept Mongo DB generated aggregated pipeline?

Answered
Younus M asked on January 11, 2023

Hi,
I need the generated pipeline that prints in the logs but doesn't clearly show in the request. Is there a way I can get that pipeline in the node JS code as its generated by flexmonster?
Thanks,
Younus

3 answers

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster January 12, 2023

Hello, Younus,

Thank you for contacting us.

Could you please provide us with more details of your use case? Which functionality do you want to achieve using the pipeline? 

Looking forward to hearing from you.

Kind regards,
Nadia

Public
Younus M January 12, 2023

I need to use the pipeline for additional testing for some of our use cases.

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster January 13, 2023

Hello, Younus,

Thank you for the response.

Kindly note that the MongoDB Connector was not designed to provide a solution for such a use case. This functionality is not supported out of the box. Here may be the following workarounds:

  1. You can store the Flexmonster queries received by the Controller. It allows you to get the data from the MongoDB Connector directly. Moreover, the results are stored in the cache, so there's no need to use and execute the pipeline. 
  2. If it is critical to access the pipelines, you can use the MongoDB Connector source code and customize it for your needs. Also, you can override the existing functionality. Here is the method where the pipeline is available before the execution: https://github.com/flexmonster/flexmonster-mongodb-connector/blob/997743b234099d23%5B…%5Db6d999566ef/src/requests/apiRequests/impl/AbstractApiRequest.ts
    Please note that this approach requires more development resources and customization. In such a case, the first option could be preferable

Please let us know in case of any other questions arise.

Kind regards,
Nadia

Please login or Register to Submit Answer