Ashok
Ashok

Reputation: 21

Smart alternative for .eval in MongoDB

Developers,

The topic may seem repetitive but I am still searching for a solution.

As part of an enterprise application, have created more than 100+ functions within MongoDB (3.4) which simply takes input, processes/aggregates data within MongoDB and returns the result set.

I use Java to call these functions (essentially embedded .js scripts) and consume the result. Java uses .eval to call. Although .eval still works, this is already deprecated and may be removed in the future releases. Also it may not work in sharded clusters.

My question:

  1. What are the alternatives for .eval for Java? I understand one answer is to implement the .js in java code itself. But this requires lot of development effort. Is there an alternative for Java to consume these functions without going through .eval route?

  2. .eval does not work in sharded collections. What are the smart alternatives?

TIA for the help, Ashok

Upvotes: 2

Views: 2001

Answers (1)

Murugan Perumal
Murugan Perumal

Reputation: 985

Eval operations are now deprecated. JS execution on server is the only way to achieve what you need like batch process. So you switch to java mongoDB driver instead of writing store procedure.

Upvotes: 1

Related Questions