diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/aql/functions.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/aql/functions.js index dbf659eb7d..34158aa57e 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/aql/functions.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/aql/functions.js @@ -293,15 +293,15 @@ var registerFunction = function (name, code, isDeterministic) { } var exists = false; - var collection = getStorage(); var result = db._executeTransaction({ collections: { - write: collection.name() + write: getStorage().name() }, action: function (params) { + var collection = require("internal").db._collection(params.collection); var name = params.name; - var collection = params.collection; + try { var doc = collection.document(name.toUpperCase()); if (doc !== null) { @@ -315,8 +315,8 @@ var registerFunction = function (name, code, isDeterministic) { var data = { _key: name.toUpperCase(), name: name, - code: code, - isDeterministic: isDeterministic || false + code: params.code, + isDeterministic: params.isDeterministic || false }; collection.save(data); @@ -324,7 +324,9 @@ var registerFunction = function (name, code, isDeterministic) { }, params: { name: name, - collection: collection + code: code, + isDeterministic: isDeterministic, + collection: getStorage().name() } }); diff --git a/js/common/modules/org/arangodb/aql/functions.js b/js/common/modules/org/arangodb/aql/functions.js index 36c35171dd..6a1e4d75df 100644 --- a/js/common/modules/org/arangodb/aql/functions.js +++ b/js/common/modules/org/arangodb/aql/functions.js @@ -292,15 +292,15 @@ var registerFunction = function (name, code, isDeterministic) { } var exists = false; - var collection = getStorage(); var result = db._executeTransaction({ collections: { - write: collection.name() + write: getStorage().name() }, action: function (params) { + var collection = require("internal").db._collection(params.collection); var name = params.name; - var collection = params.collection; + try { var doc = collection.document(name.toUpperCase()); if (doc !== null) { @@ -314,8 +314,8 @@ var registerFunction = function (name, code, isDeterministic) { var data = { _key: name.toUpperCase(), name: name, - code: code, - isDeterministic: isDeterministic || false + code: params.code, + isDeterministic: params.isDeterministic || false }; collection.save(data); @@ -323,7 +323,9 @@ var registerFunction = function (name, code, isDeterministic) { }, params: { name: name, - collection: collection + code: code, + isDeterministic: isDeterministic, + collection: getStorage().name() } });