Is it possible to run MongoDB javascript scripts in DBeaver DBeaver's wiki shows a simple query against a Mongo database but what about admin scripts?  It would be great to develop these in DBeaver but I've tried a few permutations to no avail.

Here's an example of a maintenance script:

var cursor = db.album.find({}, {"k": 1 })
var albumKeys = []

while( cursor.hasNext() ){
    albumKeys.push( cursor.next()['k']);
}

cursor = db.song.find({ "alb" : { $not : { $in : albumKeys } } } )
var songsWithMissingAlbum = []

while( cursor.hasNext() ) {
    songsWithMissingAlbum.push(cursor.next())
}

printjson(songsWithMissingAlbum)
subtle differences to the script allows this to run in DBeaver, and (with a small adaptation) as a script for mongo &lt;script.js&gt;

conn = new Mongo();
db = conn.getDB("myDB");

cursor = db.album.find({}, {'k': 1 });

albumKeys = [];

while( cursor.hasNext() ){
    albumKeys.push( cursor.next()['k']);
}




cursor = db.song.find({ 'alb' : { $not : { $in : albumKeys } } } );
songsWithMissingAlbum = [];

while( cursor.hasNext() ) {
    songsWithMissingAlbum.push(cursor.next());
}


return songsWithMissingAlbum; /* printjson(songsWithMissingAlbum) */


Pertinent changes


semicolon line terminations
final return statement (for dbeaver) which must be changed to printjson(..) call in command line script for mongo.
added db and connection setup which works in both.