Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/
MongoDB Manual
/ / /

db.eval()

db.eval(function, arguments)

Deprecated since version 3.0.

Important

Starting in version 4.2, MongoDB removes the eval command. The deprecated db.eval(), which wraps the eval command, can only be run against MongoDB 4.0 or earlier versions. For behavior and example, refer to the 4.0 or earlier version of the manual.

Provides the ability to run JavaScript code on the MongoDB server.

The method accepts the following parameters:

Parameter
Type
Description

function

function

A JavaScript function to execute.

arguments

list

Optional. A list of arguments to pass to the JavaScript function. Omit if the function does not take arguments.

The JavaScript function need not take any arguments, as in the first example, or may optionally take arguments as in the second:

function () {
// ...
}
function (arg1, arg2) {
// ...
}

Back

db.dropDatabase()

On this page