TDV Adapter for MongoDB

Build 21.0.8137

Eval

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

Stored Procedure Specific Information

You can use the EVAL stored procedure to execute JavaScript functions as stored procedures:

EXEC EVAL @jsFunction = 'function() { return db.restaurants.findOne(); }'
You can also use EVAL to save functions to system.js
EXEC EVAL @jsFunction = 'function() { db.system.js.save({ _id: "myAddFunction", value : function (x, y) { return x + y; } }); }'
And then execute stored JavaScript functions as stored procedures:
EXEC EVAL @jsFunction = 'function() { return myAddFunction(1,1); }'
You can retrieve a list of all stored JavaScript functions by querying the system.js table:
SELECT * FROM "system.js"

Input

Name Type Description
Jsfunction String A JavaScript function to execute.

Result Set Columns

Name Type Description
* String Output will vary for each collection.

Copyright (c) 2022 CData Software, Inc. - All rights reserved.
Build 21.0.8137