/** * Calls {@link DB#doEval(java.lang.String, java.lang.Object[]) }. If the command is successful, the "retval" field is extracted and * returned. Otherwise an exception is thrown. * * @param code {@code String} representation of JavaScript function * @param args arguments to pass to the JavaScript function * @return result of the execution * @throws MongoException if the operation failed * @mongodb.driver.manual reference/method/db.eval/ db.eval() * @deprecated The eval command was deprecated in MongoDB 3.0 */ @Deprecated public Object eval(final String code, final Object... args) { CommandResult result = doEval(code, args); result.throwOnError(); return result.get("retval"); }
/** * Returns server version. * * @return Server version. */ @Nonnull public String getServerVersion() { final CommandResult result = db.doEval("db.version()"); return result.getString("retval"); }
MongoClient mongoClient = new MongoClient(); DB db = mongoClient.getDB("dbName"); Model m = new Model(...); CommandResult result = db.doEval("insertDocument", model);
/** * Calls {@link DB#doEval(java.lang.String, java.lang.Object[]) }. If the command is successful, the "retval" field is extracted and * returned. Otherwise an exception is thrown. * * @param code {@code String} representation of JavaScript function * @param args arguments to pass to the JavaScript function * @return result of the execution * @throws MongoException if the operation failed * @mongodb.driver.manual reference/method/db.eval/ db.eval() * @deprecated The eval command was deprecated in MongoDB 3.0 */ @Deprecated public Object eval(final String code, final Object... args) { CommandResult result = doEval(code, args); result.throwOnError(); return result.get("retval"); }
result = db.doEval("(function() {" + instructions.toString() + "})();", new Object[0]); } catch (MongoException e) { throw new MojoExecutionException("Unable to execute file with name '" + file.getName() + "'", e);
CommandResult result = db.doEval(script); if (!result.ok()) { Exception ex = result.getException();
result = db.doEval("(function() {" + instructions.toString() + "})();", new Object[0]); } catch (MongoException e) { throw new MojoExecutionException("Unable to execute file with name '" + file.getName() + "'", e);