TCB13
TCB13

Reputation: 3155

MongoDB: Replacement for MongoDB::execute to call JS function on server

I recently found out that the MongoDB::execute method was deprecated on the PHP MongoDB extension:

MongoDB::execute — Runs JavaScript code on the database server [deprecated]

I was using this method to call some javascript functions already stored on the server, as follows:

$result= $db->execute("myTestFunction()");
print $result["retval"];

Now that MongoDB::execute no longer works, how can I call a JS function on the server? I've tried the ::command method in a bunch of ways and I get no such command: 'myTestFunction'.

My goal is to run heavy operations (that manipulate a lot of data) on the database itself avoiding having to pull the data into PHP and sending it back to other collections. In case it no longer possible to call JS functions from PHP what's the best practice here?

Thank you.

Upvotes: 1

Views: 142

Answers (1)

SoWhat
SoWhat

Reputation: 5622

There isn't an alternative. Mongodb has deperacted eval and will not be continuing support for the eval feature in the future. You have to work without it in the future

Upvotes: 1

Related Questions