Server-side JavaScript
$where, $function, $accumulator and mapReduce with an isolated interpreter.
TeselaDB runs the JavaScript of MongoDB queries: $where, $function, $accumulator and mapReduce. It does so with
its own interpreter written in Rust that only sees the documents it receives.
JavaScript
db.orders.aggregate([
{
$addFields: {
vat: {
$function: {
body: "function (total) { return Math.round(total * 0.21 * 100) / 100 }",
args: ["$total"],
lang: "js",
},
},
},
},
]);Limits
Each run has step, memory and time limits, as in MongoDB. JavaScript local dates are in UTC and BSON types show with
their MongoDB names (NumberLong, ObjectId…).
Turn it off
Start the nodes with --noscripting (or security.javascriptEnabled: false in the configuration file) and queries
with JavaScript answer with an error.
mapReduce is deprecated in MongoDB, but it stays because mongosh and the drivers still send it. For new code use the
aggregation framework.