无法访问使用" nestRemoting"创建的嵌套远程处理apI:对于belongsTo为true

时间:2018-04-20 03:36:24

标签: prototype loopbackjs loopback

我无法访问嵌套原型来禁用它或更改实现逻辑。

以下是Org.json和OrgGroup.json

Org.json

{
  "name": "Org",
  "plural": "Orgs",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "replaceOnPUT": true,
    "validateUpsert": false
  },
  "properties": {
    "name": {
      "type": "string",
      "required": true
    }
  },
  "relations": {
    "orgGroup": {
      "type": "belongsTo",
      "model": "OrgGroup",
      "foreignKey": "groupId",
      "options": {
        "nestRemoting": true
      }
    }
  },
  "acls": [],
  "methods": {}
}

OrgGroup.json

{
  "name": "OrgGroup",
  "plural": "OrgGroups",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "name": {
      "type": "string",
      "required": true
    }
  },
  "relations": {
    "orgs": {
      "type": "hasMany",
      "model": "Org",
      "foreignKey": "groupId",
      "options": {
        "nestRemoting": true
      }
    }
  },
  "acls": [],
  "methods": {}
}

我有这样的访问方法: GET /Orgs/{id}/orgGroup 我可以使用'prototype.__get__orgGroup'

捕获此内容

"nestRemoting": true由于关系而正在按预期创建以下内容:

GET /Orgs/{id}/orgGroup/orgs
GET /Orgs/{id}/orgGroup/orgs/{fk}
PUT /Orgs/{id}/orgGroup/orgs/{fk}

我想访问此嵌套api 1)禁用PUT方法PUT /Orgs/{id}/orgGroup/orgs/{fk}并为GET /Orgs/{id}/orgGroup/orgs/{fk}提供acl&#39。但是,我无法做到。我该怎么做?

以下任何一项均无效:

例如:对于嵌套的api GET /Orgs/{id}/orgGroup/orgs,我尝试过:

    prototype._get_orgGroup_orgs
    prototype.__get__orgGroup_orgs
    prototype.__find__orgGroup_orgs
    prototype._find_orgGroup_orgs
    __get__orgGroup_orgs
    __get__orgGroup__orgs
__get__orgGroupOrgs

1 个答案:

答案 0 :(得分:0)

这应该可以解决问题:

Org.disableRemoteMethodByName('prototype.__updateById__ OrgGroups')