'How to call a Mongodb Realm function from nodejs

I have a function deployed in Mongodb Realm that I want to call in my local nodejs app. I am able to connect to the Mongodb Atlas Cluster via the uri and MongoClient.

But they are only able to query the database and not call that function. Is there a way I can call that function using this connected instance of MongoClient.

I also discovered two npm packages - realm and realm-web. But I am unable to get the work done with either of them.

in realm-web, the docs says to use import like

import * as Realm from "realm";

but this doesn't work in node.

SyntaxError: Cannot use import statement outside a module

then in realm, the method to open the realm apparantly has two arguments

const Realm = require("realm");

const realm = Realm.open({
    path: "myrealm",
    schema: [TaskSchema],
  });

and I am unable to find what to fill in them.

Any suggestion or help is appreciated



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source