Search code examples
mongodbmongodb-atlasmongodb-stitch

No Matching record is found IN MongoDB Stitch app webhook function


I have a MongoDb ATLAS database as "BOULDERS_MAIN" and a collection inside it "users", I am writing a webhook function for returning a user based on email i.e. "kb", but all I'm getting is empty object.

enter image description here


Solution

  • MongoDB's find() returns a cursor object not the results. Try calling toArray() on the result instead:

    var doc = users.find({email: 'kb'}).toArray();