Recompiling JS in the arangodb codebase? (trying to hack sth into Foxx) -
i've made change .js file in arangodb codebase , did make clean && make
, restarted arangod, change doesn't seem picked up. how make sure change activated?
the changed file was: js/server/modules/org/arangodb/foxx/query.js
the docs chapter brought me idea https://docs.arangodb.com/foxx/foxxrepository.html#defining_custom_queries which, btw, doesn't show how pass arguments query , references 'chapter on foxx queries' couldn't find.
ultimately, goal pass arguments not query transform function called. diff is
diff --git a/js/server/modules/org/arangodb/foxx/query.js b/js/server/modules/org/arangodb/foxx/query.js index 49e320c..ac37f34 100644 --- a/js/server/modules/org/arangodb/foxx/query.js +++ b/js/server/modules/org/arangodb/foxx/query.js @@ -61,7 +61,7 @@ exports.createquery = function createquery (cfg) { throw new error('expected transform function.'); } - return function query(vars) { + return function query(vars, trargs) { vars = _.extend({}, defaults, vars); if (context) { _.each(vars, function (value, key) { @@ -76,6 +76,6 @@ exports.createquery = function createquery (cfg) { return new model(data); }); } - return transform ? transform(result) : result; + return transform ? transform(result, trargs:) : result; }; -}; \ no newline @ end of file +};
the repository this:
(function () { "use strict"; var foxx = require("org/arangodb/foxx"); var pingers = foxx.repository.extend({ ping: foxx.createquery({ query: "for p in pingers filter p._key == @id return p", transform: function(items, args) { var lang = args.lang; (var = 0; < items.length; i++) { var item = items[i]; item.name = item.name[lang]; item.description = item.description[lang]; } return items; } }), exports.repository = pingers; }());
and controller:
ctrl.get("/ping", function(req, res) { var id = req.param('id'); var lang = req.param('lang'); res.json(pingers.ping({id: id}, {lang: lang})); });
i should enough restart server. javascript files not pre-compiled , loaded required.
the line
return transform ? transform(result, trargs:) : result;
looks suspicious. ":" after trargs strange. should raise error.
Comments
Post a Comment