J. Doe
J. Doe

Reputation: 33

MongoDB Atlas - Trigger returning empty object

I've been trying to search through documentation, and other various stack overflow posts, but I can't seem to find out how to do this. I'm trying setup a Trigger for MongoDB Atlas with the following function:

exports = function() {
  const mongodb = context.services.get("test_cluster");
  const db = mongodb.db("test_database");
  const test_collection = db.collection("test_collection");
  var tasks = test_collection.find();
  console.log(JSON.stringify(tasks));
};

but the logs return "{}" every time I run it, is there something basic that I'm missing here? There is data in the collection with just some dummy data with a basic _id and some values.

Upvotes: 1

Views: 505

Answers (1)

J. Doe
J. Doe

Reputation: 33

I figured out my problem, Atlas does not output the information from console.log into their console through the browser. I setup the variables correctly, but to get the information I wanted I needed to use a return statement instead.

Upvotes: 2

Related Questions