{"action":"created","issue":{"url":"https://api.github.com/repos/HouzuoGuo/tiedot/issues/46","labels_url":"https://api.github.com/repos/HouzuoGuo/tiedot/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/HouzuoGuo/tiedot/issues/46/comments","events_url":"https://api.github.com/repos/HouzuoGuo/tiedot/issues/46/events","html_url":"https://github.com/HouzuoGuo/tiedot/issues/46","id":26165642,"number":46,"title":"struct (un)marshal","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2014-01-23T13:21:56Z","updated_at":"2015-08-06T15:05:16Z","closed_at":null,"body":"Hey, tiedot's great.\r\n\r\nIt would be good if tiedot supported direct struct marshal/unmarshal. There's no reason it shouldn't, as `encoding/json` supports it, and that's what tiedot's using.\r\n\r\nI see that the reason the interface has `map[string]interface{}` is to add the id field. Is this necessary? Or, could reflection be used? (structs could include the id field)."},"comment":{"url":"https://api.github.com/repos/HouzuoGuo/tiedot/issues/comments/128405315","html_url":"https://github.com/HouzuoGuo/tiedot/issues/46#issuecomment-128405315","issue_url":"https://api.github.com/repos/HouzuoGuo/tiedot/issues/46","id":128405315,"user":{"login":"kylewolfe","id":5065665,"avatar_url":"https://avatars.githubusercontent.com/u/5065665?v=3","gravatar_id":"","url":"https://api.github.com/users/kylewolfe","html_url":"https://github.com/kylewolfe","followers_url":"https://api.github.com/users/kylewolfe/followers","following_url":"https://api.github.com/users/kylewolfe/following{/other_user}","gists_url":"https://api.github.com/users/kylewolfe/gists{/gist_id}","starred_url":"https://api.github.com/users/kylewolfe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kylewolfe/subscriptions","organizations_url":"https://api.github.com/users/kylewolfe/orgs","repos_url":"https://api.github.com/users/kylewolfe/repos","events_url":"https://api.github.com/users/kylewolfe/events{/privacy}","received_events_url":"https://api.github.com/users/kylewolfe/received_events","type":"User","site_admin":false},"created_at":"2015-08-06T15:05:16Z","updated_at":"2015-08-06T15:05:16Z","body":"Thanks for the quick reply!\r\n\r\nYour proposed methods would use json to (un)marshal?\r\nWhat would idAttrName be used for?\r\n\r\nIs the idea of a single return type that can do multiple things out of the realm of possibility? Or maybe just too much of a breaking change? Ideally an interface such as this would be better, so that Id is handled by (un)marshaling:\r\n\r\n```go\r\ntype Foo struct {\r\n    Id int\r\n    Foo, Bar string\r\n}\r\n\r\nf := &Foo{Foo: \"foo\", Bar: \"bar\"}\r\nif err := col.Insert(f); err != nil {\r\n    panic(err)\r\n}\r\nfmt.Println(f.Id) // has new id\r\n\r\nf.Foo = \"baz\"\r\nif err = col.update(f); err != nil {\r\n    panic(err)\r\n}\r\n```\r\n\r\nmgo behaves this way so that I do not have to take an extra step to populate Id, if it exists. What are your thoughts?\r\n\r\nI'd be happy to start digging in and trying to make some updates to allow for this. I have a high need for embedded db usage, so it would probably be beneficial for me to poke around and understand a little more about tiedot at a lower level."}}