Get data from mongo cluster to realm function

I am trying to get data from collection to realm function but getting only object object

     const cluster ="mongodb-atlas");
   const users = cluster.db("ssn").collection("invites");
   const stories = cluster.db("ssn").collection("stories");
   const twilio ="Twilio");
   const story = await stories.find({});

Hi @Jayesh_Sharma,

You are missing the toArray() and the parsing:

Try this:

exports = function(arg){
    const collection ="mongodb-atlas").db("test").collection("test");
    collection.find({}).toArray().then((docs) => {


1 Like

hii @MaBeuLux88 , it displays only first data not all.

My function above prints all the documents in the test.test collection.

Make sure you are not using findOne() instead of find() or something like that. Also the query might be filtering more than you think?

@MaBeuLux88 , I am using the same you have told me.

Humm I know that the output of the console.log is trimmed when it’s too long. Maybe that’s it?

If you create a REST API instead and return the docs in the body of the response, it looks like this:

exports = function(payload, response) {
    const coll ="mongodb-atlas").db("test").collection("test");
    coll.find().toArray().then( docs => {

And the answer I get from the REST API looks like this:


Or like this


It depends if I use the EJSON (first output) or JSON (second one) help to stringify my docs.

To create a REST API, head into the 3rd Party Service > HTTP.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.