3

我正在 ArangoDB 的 FOXX 应用程序的存储库中尝试自定义查询:

        /*clinics.js */  

         'use strict'; 

    var Foxx = require('org/arangodb/foxx');

            var ClinicsRepository = Foxx.Repository.extend({   
// Add your custom methods here

              //Returns all procedures from a clinic, given the clinic id 
getAllProcedures: Foxx.createQuery({
                    query: 'FOR clinic IN exameFacil_clinics FILTER clinic._key == [@id] RETURN clinic.procedures',

                    params: ['id']

                })
 });

            exports.repository = ClinicsRepository;

我是按照 Foxx 食谱做的,但它总是给我一个错误:

[ArangoError 3103:调用模块文件失败:c:/Program Files/ArangoDB 2.6.2/var/lib/arangodb-apps/_db/_system/exameFacil/APP/controllers/clinics.js]

[阿朗戈错误
3103:调用模块文件失败:c:/Program Files/ArangoDB
2.6.2/var/lib/arangodb-apps/_db/_system/exameFacil/APP/controllers/clinics.js]
在 [object Object].Module.run (C:\Program Files\ArangoDB
2.6.2\bin../share/arangodb/js/common/bootstrap/modules.js:1420:20) 在 ArangoApp.loadAppScript (c:/Program Files/ArangoDB
2.6.2/share/arangodb/js/server/modules/org/arangodb/foxx/arangoApp.js:452:24)
在 mountController (c:/Program Files/ArangoDB
2.6.2/share/arangodb/js/server/modules/org/arangodb/foxx/routing.js:661:7)
在 c:/程序文件/ArangoDB
2.6.2/share/arangodb/js/server/modules/org/arangodb/foxx/routing.js:630:9
在 Array.forEach (native) at routeApp (c:/Program Files/ArangoDB
2.6.2/share/arangodb/js/server/modules/org/arangodb/foxx/routing.js:629:32)
在 Object.routes (c:/Program Files/ArangoDB
2.6.2/share/arangodb/js/server/modules/org/arangodb/foxx/manager.js:268:10)
在 foxxRouting (c:/Program Files/ArangoDB
2.6.2/share/arangodb/js/server/modules/org/arangodb/actions.js:1054:74)
在执行时(c:/Program Files/ArangoDB
2.6.2/share/arangodb/js/server/modules/org/arangodb/actions.js:1308:7) 在 Object.routeRequest (c:/Program Files/ArangoDB
2.6.2/share/arangodb/js/server/modules/org/arangodb/actions.js:1329:3) 在 Function.actions.defineHttp.callback (c:\Program Files\ArangoDB
2.6.2\share\arangodb\js\actions\api-system.js:58:15)

每当我尝试“要求”clinics.js 文件时,都会发生此错误。有什么建议么?谢谢!

4

1 回答 1

4

你能试试换行吗

exports.repository = ClinicsRepository;

module.exports = ClinicsRepository;

然后错误应该消失。

除此之外,AQL 查询中的过滤器可能需要从

FILTER clinic._key == [@id]

FILTER clinic._key == @id

或者

FILTER clinic._key IN @id

实际查找文档,具体取决于您要查找单个文档还是文档数组。

于 2015-07-30T06:56:21.607 回答