Я работаю над Loopback 4 API, который обрабатывает полезные нагрузки JSON-LD.Следующее позволяет мне выполнять запросы от родителя к потомку и наоборот без проблем:
// Inside Parent entity
@hasMany(() => Child, {keyTo: 'parentCode'})
'children': Child[];
// Inside Child entity
@belongsTo(() => Parent)
'parentCode': string;
Однако, как только я включаю префиксы, определенные как часть моего JSON-LD, тогда пытаюсь вызвать /parents/{id}/child
...:
// Inside Parent entity
@hasMany(() => Child, {keyTo: 'foo:ParentCode'})
'children': Child[];
// Inside Child entity
@belongsTo(() => Parent)
'foo:ParentCode': string;
... Я получаю следующую ошибку:
Unhandled error in GET /skilllevels/Z/majorgroups: 500 AqlError: Not a valid simple reference: result.noc:ParentSkillLevel
at new AqlError (/home/max/git/esdc/noc-arangodb/node_modules/aqb/errors.js:5:13)
at new SimpleReference (/home/max/git/esdc/noc-arangodb/node_modules/aqb/types.js:403:11)
at Function.castString [as string] (/home/max/git/esdc/noc-arangodb/node_modules/aqb/types.js:64:10)
at Object.autoCastToken (/home/max/git/esdc/noc-arangodb/node_modules/aqb/types.js:88:29)
at Function.QB.(anonymous function) [as eq] (/home/max/git/esdc/noc-arangodb/node_modules/aqb/index.js:43:13)
at /home/max/git/esdc/noc-arangodb/node_modules/loopback-connector-arangodb/lib/arangodb.js:830:37
at ArangoDBConnector._buildWhere (/home/max/git/esdc/noc-arangodb/node_modules/loopback-connector-arangodb/lib/arangodb.js:836:9)
at ArangoDBConnector.all (/home/max/git/esdc/noc-arangodb/node_modules/loopback-connector-arangodb/lib/arangodb.js:868:22)
at invokeConnectorMethod (/home/max/git/esdc/noc-arangodb/node_modules/loopback-datasource-juggler/lib/dao.js:172:21)
at /home/max/git/esdc/noc-arangodb/node_modules/loopback-datasource-juggler/lib/dao.js:1712:7
at doNotify (/home/max/git/esdc/noc-arangodb/node_modules/loopback-datasource-juggler/lib/observer.js:156:49)
at doNotify (/home/max/git/esdc/noc-arangodb/node_modules/loopback-datasource-juggler/lib/observer.js:156:49)
at Function.ObserverMixin._notifyBaseObservers (/home/max/git/esdc/noc-arangodb/node_modules/loopback-datasource-juggler/lib/observer.js:179:5)
at Function.ObserverMixin.notifyObserversOf (/home/max/git/esdc/noc-arangodb/node_modules/loopback-datasource-juggler/lib/observer.js:154:8)
at Function.ObserverMixin._notifyBaseObservers (/home/max/git/esdc/noc-arangodb/node_modules/loopback-datasource-juggler/lib/observer.js:177:15)
at Function.ObserverMixin.notifyObserversOf (/home/max/git/esdc/noc-arangodb/node_modules/loopback-datasource-juggler/lib/observer.js:154:8)
Возможно, это связано с двоеточием :
внутри имени свойства.Я пытался установить имя отношения.Хотя он не выдает ошибку, пока я настроил дочерний репозиторий, он всегда возвращает пустой массив:
// Inside Parent entity
@hasMany(() => Child, {keyTo: 'ParentCode'})
'children': Child[];
// Inside Child entity
@belongsTo(() => Parent, {name: 'ParentCode'})
'foo:ParentCode': string;
В других ситуациях, когда :
или другие символы вызывали проблемы, ябудет использовать обозначение Object['key']
.Но я не понимаю, как я мог это сделать, учитывая, что ошибка исходит от более низкого уровня платформы.Есть ли способ заставить отношения работать, сохраняя :
внутри имени свойства?