Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support calling of MongoDB stored javascripts [DATAMONGO-479] #1364

Closed
spring-projects-issues opened this issue Jul 9, 2012 · 4 comments
Closed
Assignees
Labels
in: repository type: enhancement

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jul 9, 2012

Benj Sicam opened DATAMONGO-479 and commented

Support calling of mongodb stored javascripts


Affects: 1.0.2

Issue Links:

  • DATAMONGO-1112 Add repository support via annotations for calling server side scripts
    ("is depended on by")
  • DATACMNS-614 Add common infrastructure calling stored procedures via repository interfaces

Referenced from: pull request #254

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 16, 2012

Oliver Drotbohm commented

Can you please give a bit more information about the request? What is you usage scenario? What API do you think of? How would you like to call the javascripts?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Apr 18, 2013

Benj Sicam commented

Hello Oliver,

Kindly close this. I was wrong to file this request. Thanks!

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Dec 4, 2014

Christoph Strobl commented

Sorry Benj Sicam, I've been a bit too fast in closing this one. The idea is interesting

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Dec 4, 2014

Christoph Strobl commented

To outline the potential API a bit...

The mongodb driver allows calling and registering functions:

// directly evaluate a function with parameters
db.eval("function(x) { return x; }", "10")

// register and call function by name
db.getCollection("system.js")
  .save(
    new BasicDBObject("_id", "echoFunction")
              .append("value", new Code("function(x) { return x; }"))
  );

Object o = db.eval("echoFunction(10)");

So we can add eval to MongoTemplate allowing to call functions.
With that in place we could add @Procedure to DATACMNS to set up the basic infrastructure (as we already have something similar in DATAJPA).

@Procedure(value="function(x) { return x; }")
Integer directExecution(String arg0);

@Procedure(name="echoFunction")
Integer viaFunctionId(String arg0);

We could also check properties files for presence of scripts and pre register those at startup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: repository type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants