I'm trying to call stored function from node js using db.eval() and also provided the db connection and it is giving an error - Type Error: db.eval() is not a function.
I'm facing difficulty while calling the stored functions, if anyone know anything it would be helpful,
Thanks i appreciate it.
Here is the function i stored in mongodb.
db.system.js.save({
"_id":"getNumbers",
"value": function (){
return db.numbers.find()
}
})
db.loadServerScripts()
The below snippet that i used for calling stored function, and dbConnection is where i written code for connecting mongo db
const dbConnection =
require("./dbConnection");
function getNum(result) {
dbConnection.db.eval("getNumbers()", (err, res) => {
if (err) {
return result(err);
} else {
return result(res);
}
}
}