Is it OK, to perform server-side execution of JavaScript code, in MongoDB (using db.eval)?
For Example:
I want to reduce lot of code related to transformation of data on my node app, and move all of that logic to a script file and execute it via db.eval, Is this recommended?
Instinctively I'd be very weary of using db.eval and find another way. What version of MongoDB are you using ? Does the code take user input that is liable to code injection ? This function has some severe side effects, for example, it blocks all reads and writes.
The function has been deprecated as of MongoDB 3.0 - the techies at MongoDB must have thought there was a good reason not to have that function at all, so you may want to take this into consideration !
Justin Njoh
MVPs & POCs on NoSQL DBs - why not ?
Instinctively I'd be very weary of using db.eval and find another way. What version of MongoDB are you using ? Does the code take user input that is liable to code injection ? This function has some severe side effects, for example, it blocks all reads and writes.
The function has been deprecated as of MongoDB 3.0 - the techies at MongoDB must have thought there was a good reason not to have that function at all, so you may want to take this into consideration !