-
Notifications
You must be signed in to change notification settings - Fork 1.1k
DATAMONGO-479 - Add support for calling functions. #254
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
Conversation
@@ -110,6 +112,8 @@ public CustomConversions(List<?> converters) { | |||
toRegister.add(StringToURLConverter.INSTANCE); | |||
toRegister.add(DBObjectToStringConverter.INSTANCE); | |||
toRegister.add(TermToStringConverter.INSTANCE); | |||
toRegister.add(CallableMongoScriptToDBObjectConverter.INSTNACE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed - thanks @thomasdarimont !
9451c0c
to
be38efa
Compare
0df88c6
to
b65ddd5
Compare
* @param name | ||
* @return {@literal null} if not found. | ||
*/ | ||
CallableMongoScript load(Serializable name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why Serializable? For supporting String and ObjectIds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Yes, would have been for calling scripts via ObjectId
, but once I tried to do so it turned out that one can store the script using ObjectId
but won't be able to call it later as the name needs to be a String
. Should be String
instead of Serializable
then.
ff494b7
to
c7db98b
Compare
Prepare issue branch.
We added ScriptOperations to MongoTemplate. Those allow storage and execution of java script function directly on the MongoDB server instance. Having ScriptOperations in place builds the foundation for annotation driver support in repository layer.
Fix broken tests by avoiding initialization of MongoRepositories on package as this would trigger index creation which is likely to fail on older server versions.
Use more explicit wording and add methods for checking existence of functions via name as well as listing names of available scripts. Updated javaDoc and reference documentation.
c7db98b
to
3c442c0
Compare
Use getCode() instead of toString for converting o.b.t.Code objects. This works fine for MongoDB Java driver versions 2 and 3.
3c442c0
to
7f86a05
Compare
We added ScriptOperations to MongoTemplate. Those allow storage and execution of java script function directly on the MongoDB server instance. Having ScriptOperations in place builds the foundation for annotation driver support in repository layer. Original pull request: #254.
Removed ServersideJavaScript abstraction as we still had to resort on instanceof checks and it created more ambiguities than it helped (e.g. in a script with name and code, which of the two get's executed?). We now have an ExecutableMongoScript which is code only and a NamedMongoScript, which basically is the former assigned to a name. Execution can be triggered on the former or a name. ScriptOperations.exists(…) now returns a primitive boolean to avoid null checks. JavaDoc. Original pull request: #254.
We added
ScriptOperations
toMongoTemplate
. Those allow storage and execution of javascript function directly on the MongoDB server instance. HavingScriptOperations
in place builds the foundation for annotation driver support in repository layer.