{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/661","labels_url":"https://api.github.com/repos/facebook/immutable-js/issues/661/labels{/name}","comments_url":"https://api.github.com/repos/facebook/immutable-js/issues/661/comments","events_url":"https://api.github.com/repos/facebook/immutable-js/issues/661/events","html_url":"https://github.com/facebook/immutable-js/issues/661","id":111876801,"number":661,"title":"Add getPath method to every record","user":{"login":"vojtatranta","id":4154045,"avatar_url":"https://avatars.githubusercontent.com/u/4154045?v=3","gravatar_id":"","url":"https://api.github.com/users/vojtatranta","html_url":"https://github.com/vojtatranta","followers_url":"https://api.github.com/users/vojtatranta/followers","following_url":"https://api.github.com/users/vojtatranta/following{/other_user}","gists_url":"https://api.github.com/users/vojtatranta/gists{/gist_id}","starred_url":"https://api.github.com/users/vojtatranta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vojtatranta/subscriptions","organizations_url":"https://api.github.com/users/vojtatranta/orgs","repos_url":"https://api.github.com/users/vojtatranta/repos","events_url":"https://api.github.com/users/vojtatranta/events{/privacy}","received_events_url":"https://api.github.com/users/vojtatranta/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-16T17:37:11Z","updated_at":"2015-10-29T10:06:33Z","closed_at":null,"body":"I've been listing through some articles and lots of issues here on Github but I haven't found answer to idea I've got.\r\n\r\nIf I edit some record in the list somewhere deep in structure tree and pass it on to some store / action creator, in the store I have to somehow find this record again to edit something inside it or maybe delete it. Sure, I can use cursor to simplify this step but I would have to loop through records in the list in order to find that particular record according to ID or something.\r\n\r\nPassing on index of this record along with ID (which is needed for API fetch) seems kind a strange to me...\r\n\r\nSo I got and idea that it would be nice if I had some getPath() method on record, or just record.path because then I could just do in my store something like:\r\n```\r\nupdateById(id, record.getPath(), {name: 'john doe'})\r\n\r\nupdateById(id, path, updateObj) {\r\n   state = state.updateIn(path, prev => prev.merge(updateObj))\r\n}\r\n```\r\nInstead of:\r\n```\r\nupdateById(id, {name: 'john doe'})\r\n\r\nupdateById(id, updateObj) {\r\n  state = state.updateIn(findPathWithLoopById(id), prev => prev.merge(updateObj)))\r\n}\r\n```\r\n\r\nSince we have to loop through whole json or some other structure when we do immutable.fromJS() there would be no impact on performance, right?\r\n\r\nOr I would appreciate if you point me to some other solution for this which is already out there and I miss it.\r\n\r\nThank you so much for all the great work you have done!\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/comments/152134511","html_url":"https://github.com/facebook/immutable-js/issues/661#issuecomment-152134511","issue_url":"https://api.github.com/repos/facebook/immutable-js/issues/661","id":152134511,"user":{"login":"tomwidmer","id":1503640,"avatar_url":"https://avatars.githubusercontent.com/u/1503640?v=3","gravatar_id":"","url":"https://api.github.com/users/tomwidmer","html_url":"https://github.com/tomwidmer","followers_url":"https://api.github.com/users/tomwidmer/followers","following_url":"https://api.github.com/users/tomwidmer/following{/other_user}","gists_url":"https://api.github.com/users/tomwidmer/gists{/gist_id}","starred_url":"https://api.github.com/users/tomwidmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomwidmer/subscriptions","organizations_url":"https://api.github.com/users/tomwidmer/orgs","repos_url":"https://api.github.com/users/tomwidmer/repos","events_url":"https://api.github.com/users/tomwidmer/events{/privacy}","received_events_url":"https://api.github.com/users/tomwidmer/received_events","type":"User","site_admin":false},"created_at":"2015-10-29T10:06:33Z","updated_at":"2015-10-29T10:06:33Z","body":"A single record can be used in many different lists and immutable structures, so which path to return? If you move the record, do you want to change the path in the *immutable* record?\r\n\r\nIf you want a simpler lookup, you could maintain a separate map from id to path. Or you could change your data structure so you have an ordered map from id to record rather than a list (you can always get the list back if you need it using toList())."}}