How to use mongodb in function node?

Hi team,

I cannot able to connect MongoDB to the function node. it’s working in the MongoDB node.
but in my case need to access the function node.

any way to connect.
here client console is printing, but the data console is not printed.


Hey @rajesh-kumar, your screenshot shows that some data is actually printed to the console:

I am not familiar with the mondodb library you are using here, but some of these methods might simply be promises requiring await (meaning without await the node execution has already finished by the time they resolve). A mongodb community might be able to help you better here.

A more n8n-friendly way of connecting to MongoDB would be the use of the respective node though, which would take care of the implementation for you.