Querying App User by Email in a Serverless Function

Wondering if there’s currently a way to lookup an app user by email within a serverless function. I’m trying to setup a webhook where I can pass in a email address, and update a piece of userData.

// This function is the endpoint's request handler.
exports = function({ query, headers, body}, response) {
    const {email} = query;
    const mongodb = context.services.get("mongodb-atlas");
    // query realm app users by email to retrieve userId ?????

    if (userId){
      const collection = mongodb.db('dbname').collection('userData')
      const filter = { userId }
      const update = {
        $set: { variable: true },
      }
      collection.updateOne(filter, update) 
    }*/
    return  {}
};```
1 Like