{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/735","labels_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/735/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/735/comments","events_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/735/events","html_url":"https://github.com/strongloop/loopback-datasource-juggler/issues/735","id":110991703,"number":735,"title":"[AssertionError] The ids argument must be an array","user":{"login":"listepo","id":2510800,"avatar_url":"https://avatars.githubusercontent.com/u/2510800?v=3","gravatar_id":"","url":"https://api.github.com/users/listepo","html_url":"https://github.com/listepo","followers_url":"https://api.github.com/users/listepo/followers","following_url":"https://api.github.com/users/listepo/following{/other_user}","gists_url":"https://api.github.com/users/listepo/gists{/gist_id}","starred_url":"https://api.github.com/users/listepo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/listepo/subscriptions","organizations_url":"https://api.github.com/users/listepo/orgs","repos_url":"https://api.github.com/users/listepo/repos","events_url":"https://api.github.com/users/listepo/events{/privacy}","received_events_url":"https://api.github.com/users/listepo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/labels/doc","name":"doc","color":"d4c5f9"},{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/labels/triage","name":"triage","color":"eb6420"}],"state":"open","locked":false,"assignee":{"login":"raymondfeng","id":540892,"avatar_url":"https://avatars.githubusercontent.com/u/540892?v=3","gravatar_id":"","url":"https://api.github.com/users/raymondfeng","html_url":"https://github.com/raymondfeng","followers_url":"https://api.github.com/users/raymondfeng/followers","following_url":"https://api.github.com/users/raymondfeng/following{/other_user}","gists_url":"https://api.github.com/users/raymondfeng/gists{/gist_id}","starred_url":"https://api.github.com/users/raymondfeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raymondfeng/subscriptions","organizations_url":"https://api.github.com/users/raymondfeng/orgs","repos_url":"https://api.github.com/users/raymondfeng/repos","events_url":"https://api.github.com/users/raymondfeng/events{/privacy}","received_events_url":"https://api.github.com/users/raymondfeng/received_events","type":"User","site_admin":false},"milestone":null,"comments":10,"created_at":"2015-10-12T14:57:50Z","updated_at":"2015-10-19T21:13:13Z","closed_at":null,"body":"Model: \r\n```json\r\n{\r\n  \"name\": \"Client\",\r\n  \"base\": \"User\",\r\n  \"idInjection\": true,\r\n  \"options\": {\r\n    \"validateUpsert\": true\r\n  },\r\n  \"properties\": {\r\n    \"name\": {\r\n      \"type\": \"string\",\r\n      \"required\": true\r\n    },\r\n    \"surname\": {\r\n      \"type\": \"string\",\r\n      \"required\": true\r\n    },\r\n    \"position\": {\r\n      \"type\": \"string\",\r\n      \"required\": true\r\n    },\r\n    \"phone\": {\r\n      \"type\": \"string\",\r\n      \"required\": true\r\n    },\r\n    \"birthday\": {\r\n      \"type\": \"string\"\r\n    }\r\n  },\r\n  \"validations\": [],\r\n  \"relations\": {\r\n    \"statuses\": {\r\n      \"type\": \"referencesMany\",\r\n      \"model\": \"ClientStatus\",\r\n      \"property\": \"statuses\",\r\n      \"foreignKey\": \"statuses\"\r\n    }\r\n  },\r\n  \"acls\": [],\r\n  \"methods\": {}\r\n}\r\n```\r\n> GET http://localhost:3000/api/Clients/561b8536562e5969dec51a98/statuses\r\n```json\r\n{\r\n  \"error\": {\r\n    \"name\": \"AssertionError\",\r\n    \"status\": 500,\r\n    \"message\": \"The ids argument must be an array\",\r\n    \"actual\": false,\r\n    \"expected\": true,\r\n    \"operator\": \"==\",\r\n    \"generatedMessage\": false,\r\n    \"stack\": \"AssertionError: The ids argument must be an array\\n    at Function.DataAccessObject.findByIds (/Users/ivan/work/roi4cio/api/node_modules/loopback-datasource-juggler/lib/dao.js:905:3)\\n    at ReferencesMany.related (/Users/ivan/work/roi4cio/api/node_modules/loopback-datasource-juggler/lib/relation-definition.js:2966:18)\\n    at ScopeDefinition.method [as related] (/Users/ivan/work/roi4cio/api/node_modules/loopback-datasource-juggler/lib/relation-definition.js:727:33)\\n    at Function.f (/Users/ivan/work/roi4cio/api/node_modules/loopback-datasource-juggler/lib/scope.js:210:29)\\n    at ModelConstructor.fn [as __get__statuses] (/Users/ivan/work/roi4cio/api/node_modules/loopback-datasource-juggler/lib/scope.js:275:7)\\n    at SharedMethod.invoke (/Users/ivan/work/roi4cio/api/node_modules/loopback/node_modules/strong-remoting/lib/shared-method.js:248:25)\\n    at HttpContext.invoke (/Users/ivan/work/roi4cio/api/node_modules/loopback/node_modules/strong-remoting/lib/http-context.js:384:12)\\n    at /Users/ivan/work/roi4cio/api/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:620:11\\n    at execStack (/Users/ivan/work/roi4cio/api/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:460:7)\\n    at RemoteObjects.execHooks (/Users/ivan/work/roi4cio/api/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:464:10)\"\r\n  }\r\n}\r\n```\r\n\r\nProblem in ``` ReferencesMany.prototype.related``` (relation-definition.js)\r\n\r\n> console.log(fk);\r\n\r\n```javascript\r\nstatuses\r\n```\r\n\r\n> console.log(self);\r\n\r\n```javascript\r\n{ password: '$2a$10$VIt0Wf.JDbuvZyuR0fNOIOC2gsMf7qrw8GONZS6/L7TryLOu9LSy6',\r\n  email: 'efcerfvrgv@ecefc.ru',\r\n  name: 'fvrvev',\r\n  surname: 'rvrevrv',\r\n  position: 'rvrvrvr',\r\n  statuses: [ 561b7b10562e5969dec51a59, 561b7b10562e5969dec51a58 ],\r\n  phone: '+09 (989) 898-9879',\r\n  birthday: '2015-10-21T21:00:00.000Z',\r\n  id: 561b8536562e5969dec51a98 }\r\n```\r\n\r\n> console.log(typeof ids);\r\n\r\n```javascript\r\nfunction\r\n```\r\n\r\n> console.log(ids.toString());\r\n\r\n```javascript\r\nfunction (condOrRefresh, options, cb) {\r\n        if (arguments.length === 0) {\r\n          if (typeof f.value === 'function') {\r\n            return f.value(self);\r\n          } else if (self.__cachedRelations) {\r\n            return self.__cachedRelations[name];\r\n          }\r\n        } else {\r\n          if (typeof condOrRefresh === 'function'\r\n            && options === undefined && cb === undefined) {\r\n            // customer.orders(cb)\r\n            cb = condOrRefresh;\r\n            options = {};\r\n            condOrRefresh = undefined;\r\n          } else if (typeof options === 'function' && cb === undefined) {\r\n            // customer.orders(condOrRefresh, cb);\r\n            cb = options;\r\n            options = {};\r\n          }\r\n          options = options || {}\r\n          // Check if there is a through model\r\n          // see https://github.com/strongloop/loopback/issues/1076\r\n          if (f._scope.collect &&\r\n            condOrRefresh !== null && typeof condOrRefresh === 'object') {\r\n            //extract the paging filters to the through model\r\n            ['limit','offset','skip','order'].forEach(function(pagerFilter){\r\n                if(typeof(condOrRefresh[pagerFilter]) !== 'undefined'){\r\n                    f._scope[pagerFilter] = condOrRefresh[pagerFilter];\r\n                    delete condOrRefresh[pagerFilter];\r\n                }\r\n            });\r\n            // Adjust the include so that the condition will be applied to\r\n            // the target model\r\n            f._scope.include = {\r\n              relation: f._scope.collect,\r\n              scope: condOrRefresh\r\n            };\r\n            condOrRefresh = {};\r\n          }\r\n          return definition.related(self, f._scope, condOrRefresh, options, cb);\r\n        }\r\n      }\r\n```"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/comments/149349195","html_url":"https://github.com/strongloop/loopback-datasource-juggler/issues/735#issuecomment-149349195","issue_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/735","id":149349195,"user":{"login":"crandmck","id":2925364,"avatar_url":"https://avatars.githubusercontent.com/u/2925364?v=3","gravatar_id":"","url":"https://api.github.com/users/crandmck","html_url":"https://github.com/crandmck","followers_url":"https://api.github.com/users/crandmck/followers","following_url":"https://api.github.com/users/crandmck/following{/other_user}","gists_url":"https://api.github.com/users/crandmck/gists{/gist_id}","starred_url":"https://api.github.com/users/crandmck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crandmck/subscriptions","organizations_url":"https://api.github.com/users/crandmck/orgs","repos_url":"https://api.github.com/users/crandmck/repos","events_url":"https://api.github.com/users/crandmck/events{/privacy}","received_events_url":"https://api.github.com/users/crandmck/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T21:13:13Z","updated_at":"2015-10-19T21:13:13Z","body":"I added a note to docs (https://docs.strongloop.com/display/LB/Creating+model+relations and https://docs.strongloop.com/display/LB/Relation+generator) and created above issue to improve the relation generator CLI tool. \r\n\r\nCan this issue be closed now?"}}