{"action":"created","issue":{"url":"https://api.github.com/repos/i-e-b/node-tree-surgeon/issues/5","labels_url":"https://api.github.com/repos/i-e-b/node-tree-surgeon/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/i-e-b/node-tree-surgeon/issues/5/comments","events_url":"https://api.github.com/repos/i-e-b/node-tree-surgeon/issues/5/events","html_url":"https://github.com/i-e-b/node-tree-surgeon/issues/5","id":69853990,"number":5,"title":"Decompose to include object types","user":{"login":"AGascoigne","id":8590350,"avatar_url":"https://avatars.githubusercontent.com/u/8590350?v=3","gravatar_id":"","url":"https://api.github.com/users/AGascoigne","html_url":"https://github.com/AGascoigne","followers_url":"https://api.github.com/users/AGascoigne/followers","following_url":"https://api.github.com/users/AGascoigne/following{/other_user}","gists_url":"https://api.github.com/users/AGascoigne/gists{/gist_id}","starred_url":"https://api.github.com/users/AGascoigne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AGascoigne/subscriptions","organizations_url":"https://api.github.com/users/AGascoigne/orgs","repos_url":"https://api.github.com/users/AGascoigne/repos","events_url":"https://api.github.com/users/AGascoigne/events{/privacy}","received_events_url":"https://api.github.com/users/AGascoigne/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/i-e-b/node-tree-surgeon/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"i-e-b","id":576220,"avatar_url":"https://avatars.githubusercontent.com/u/576220?v=3","gravatar_id":"","url":"https://api.github.com/users/i-e-b","html_url":"https://github.com/i-e-b","followers_url":"https://api.github.com/users/i-e-b/followers","following_url":"https://api.github.com/users/i-e-b/following{/other_user}","gists_url":"https://api.github.com/users/i-e-b/gists{/gist_id}","starred_url":"https://api.github.com/users/i-e-b/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/i-e-b/subscriptions","organizations_url":"https://api.github.com/users/i-e-b/orgs","repos_url":"https://api.github.com/users/i-e-b/repos","events_url":"https://api.github.com/users/i-e-b/events{/privacy}","received_events_url":"https://api.github.com/users/i-e-b/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-04-21T14:01:48Z","updated_at":"2015-04-21T14:30:39Z","closed_at":null,"body":"\r\n## Decompose with node (object) types  ##\r\n*tree-surgeon* labels each relations with a \"Kind\", this is how the parent refers to the child in the relation. \"Kind\" is essential as it provides the method for composing the POJO again from the relational model. For example, decomposing the following:\r\n\r\n    var person = {\r\n\t    Name: \"Someone\",\r\n\t    Landline: {\r\n\t\t    CountryCode: \"44\",\r\n\t\t    Number: \"1234567890\"\r\n\t\t},\r\n\t    Mobile: {\r\n\t\t    CountryCode: \"44\",\r\n\t\t    Number: \"7776667777\"\r\n\t\t},\r\n\t}\r\nmarks the Relation between *person* and the *Telephone Numbers* with the Kinds of \"Landline\" and \"Mobile\". \r\n\r\nThis becomes problematic if the user wishes to work with all phone numbers; with the current version this would require either inspecting all nodes to decide they are a phone number of making multiple \"xxxxByKind\" calls as long as the Kinds were known.\r\n\r\nThe proposal is to decorate Relations in the relational model which *tree-surgeon* builds with an additional (string) property indicating the ObjectType of the Child (name suggestions: ChildType, ObjectType, Node Type etc.). \r\n\r\n### Changes ###\r\n\r\n 1. **decompose** The determination of the ObjectType will be done via a function passed to the Decompose method. The function will be similar to the function to pick Ids, it will accept a single parameter of the child object and it will return the name of the ObjectType.\r\n 2. **xxxxByType methods** Provide methods similar to the \"xxxByKind\" methods to work on sets of the same type, for example `chopByType(type, predicate, relationalModel)` -- *given the name of an ObjectType it will call the provided data predicate for each child which matches the type.*"},"comment":{"url":"https://api.github.com/repos/i-e-b/node-tree-surgeon/issues/comments/94814931","html_url":"https://github.com/i-e-b/node-tree-surgeon/issues/5#issuecomment-94814931","issue_url":"https://api.github.com/repos/i-e-b/node-tree-surgeon/issues/5","id":94814931,"user":{"login":"i-e-b","id":576220,"avatar_url":"https://avatars.githubusercontent.com/u/576220?v=3","gravatar_id":"","url":"https://api.github.com/users/i-e-b","html_url":"https://github.com/i-e-b","followers_url":"https://api.github.com/users/i-e-b/followers","following_url":"https://api.github.com/users/i-e-b/following{/other_user}","gists_url":"https://api.github.com/users/i-e-b/gists{/gist_id}","starred_url":"https://api.github.com/users/i-e-b/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/i-e-b/subscriptions","organizations_url":"https://api.github.com/users/i-e-b/orgs","repos_url":"https://api.github.com/users/i-e-b/repos","events_url":"https://api.github.com/users/i-e-b/events{/privacy}","received_events_url":"https://api.github.com/users/i-e-b/received_events","type":"User","site_admin":false},"created_at":"2015-04-21T14:30:39Z","updated_at":"2015-04-21T14:30:39Z","body":"This could probably be done quite lightly by further abstracting some of the `pickIdsBy...` functions."}}