{"id":93274,"date":"2020-04-01T10:59:04","date_gmt":"2020-04-01T02:59:04","guid":{"rendered":"http:\/\/4563.org\/?p=93274"},"modified":"2020-04-01T10:59:04","modified_gmt":"2020-04-01T02:59:04","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-threft-struct-%e5%ae%9a%e4%b9%89-mgo-%e7%9a%84-objectid","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=93274","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 Threft struct \u5b9a\u4e49 mgo \u7684 objectId?"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5982\u4f55\u4f7f\u7528 Threft struct \u5b9a\u4e49 mgo \u7684 objectId?               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Zach369 <\/span>  <span><i><\/i> 33<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6211\u9047\u5230\u4e86\u8fd9\u6837\u4e00\u4e2a\u95ee\u9898:<\/p>\n<p>\u6211\u9700\u8981\u751f\u6210\u7684 go struct \u662f:<\/p>\n<pre><code>type Base struct {  ID bson.ObjectId `bson:\"_id\" json:\"id,omitempty\"` }  <\/code><\/pre>\n<p>\u4f46\u662f thrift,\u6211\u4e0d\u77e5\u9053\u600e\u4e48\u5199?<\/p>\n<pre><code>struct Base {     1:?  ID (go.tag = 'bson:\"_id\" json:\"id,omitempty\"') }  <\/code><\/pre>\n<p>bson.ObjectId \u662f github.com\/globalsign\/mgo\/bson \u7684\u5185\u5bb9<\/p>\n<p>\u6709\u4f7f\u7528\u8fc7 threft \u751f\u6210 go \u7684 struct \u7684\u5417? mongodb \u7684 objectId \u5982\u4f55\u5904\u7406\u90a3?<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1015791\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tairan2006 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5927\u54e5\u9519\u522b\u5b57\u592a\u591a\u4e86\u5427\u2026\u7528 string \u5c31\u884c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1015792\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : whalegao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u81ea\u5df1\u5b9a\u4e49\u4e00\u4e2a\u5c31\u884c\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1015793\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Zach369 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @tairan2006 \u989d \u6628\u5929\u5199\u7684\u6709\u7684\u6025 ,,,,, \u786e\u5b9e\u9519\u522b\u5b57\u6709\u70b9\u591a&#8230;&#8230; \u4e0d\u8fc7\u6211\u7528 string \u751f\u6210 string \u7684 id mgo \u63d2\u5165\u7684\u65f6\u5019\u62a5\u9519<\/p>\n<p>@whalegao \u80fd\u8bf4\u4e0b\u5177\u4f53\u600e\u4e48\u505a\u5417? \u81ea\u5df1\u5b9a\u4e49, \u5c31\u5f97\u5b9e\u73b0\u8fd9\u4e2a\u751f\u6210 id \u7684\u65b9\u6cd5\u554a                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1015794\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tairan2006 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Zach369 string \u548c ObjectId \u53ef\u4ee5\u76f8\u4e92\u8f6c\u6362\u7684\uff0c\u4f60 insert \u7684\u65f6\u5019\u4e0d\u7528\u6307\u5b9a id\uff0c\u8ba9 mongo \u81ea\u52a8\u751f\u6210\uff1b\u8bfb\u53d6\u7684\u65f6\u5019\u628a ObjectId \u8f6c\u7ed9\u5ba2\u6237\u7aef\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528 Threft struc&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/93274"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=93274"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/93274\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=93274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=93274"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=93274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}