How to call a MongoDB function

Hi,

I finished my first mongo function. I want to know where I call this function so I can access the data it calls. Would I call it in sagas.js? Or directly into my code where I need it called? Anything helps!

Thanks,

-Josh

Hi @Josh_Stout,

A function can be called from verious places. If you specify its as private it can only be called internally from your hosted application components like other functions, rules or triggers.

If you specify it as NOT private it can be called via one of our SDKs used in your client code

https://docs.mongodb.com/realm/functions/call-a-function/#call-from-a-client-application

You can also build functions to interact with data via http or other services

Let me know if that helps.

Pavel

Hello,

Could you tell me please how can a function be called from other functions internally?

You can find an example of it in the placeholder function content when creating one via the UI:

  // To call other named functions:
  // var result = context.functions.execute("function_name", arg1, arg2);
1 Like

Thank you so much, I have completely missed that line!