Is it possible to run MongoDB javascript scripts in DBeaver
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.