简体   繁体   English

Arango查询我有它在外壳中工作,但不能在Arango / Foxx中工作

[英]Arango query I have it working in the shell but can't getting working in Arango/Foxx

db.broad_broad.byExample({"location":"space_1"}).toArray()

with my database this returns 与我的数据库返回

[ 
  { 
    "_id" : "broad_broad/416394873974", 
    "_key" : "416394873974", 
    "_rev" : "554852115738", 
    "location" : "space_1", 
    "space_1" : { 
      "players" : { 
        "2" : [ 
          "ninja" 
        ] 
      } 
    } 
  } 
]

after many hours can make this happen in Foxx 很多小时后,这可以在Foxx中实现

i am not sure if i understand the question correctly so let me repeat it in my words: You have the query 我不确定我是否正确理解了这个问题,所以让我用我的话重复一下:您有查询

db.broad_broad.byExample({"location":"space_1"}).toArray()

which is working in arangosh as expected. 正按预期在arangosh工作。 Then you copied it to a Foxx app and it is not working, correct? 然后,您将其复制到Foxx应用程序,并且无法正常工作,对吗?

Most likely it is a missing require for the internal db module, which is always loaded in the shell, but not loaded in the Foxx environment. 内部db模块很可能缺少此require ,该模块始终加载在外壳程序中,而未加载到Foxx环境中。

The following minimal Foxx App should work for your example: 以下最小Foxx应用程序应适用于您的示例:

var db = require("internal").db; // Mind this line here
var Foxx = require("org/arangodb/foxx");
var app = new Foxx.Controller(applicationContext);

/** Short description
 *
 * Long description.
 */
app.get("/test", function(req, res) {
  var result = db.broad_broad.byExample({"location":"space_1"}).toArray();
  res.json(result);
});

If this does not solve your issue is it possible to you to find the error message in the server log to help me debugging? 如果这不能解决您的问题,是否可以在服务器日志中找到错误消息来帮助我进行调试?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM