MongoDB equivalent of Stored Procedures

Hi,

I am wondering what is the MongoDB equivalent of Stored Procedures.

All my searches seem to point server side javascript functions, but there doesn’t seem to be much documentation on those functions (and there’s a big disclaimer in your docs that seems to imply that MongoDB does not recommend using them).

What is the recommended MongoDB equivalent?

Thanks,
Xavier

Search for “Stored Procedure” in MongoDB docs

Search for “Stored Procedure” on Stack Overflow:

FYI here’s one of my “stored procedures”

db.system.js.save({ _id : "getUser" , value : function (emailAddress){ return db.users.aggregate([ {$match: {email: emailAddress}}, { $lookup: { from: "activitiesbuckets", localField: "_id", foreignField: "user", as: "activities" } } ]); }

1 Like