{"id":164312,"date":"2020-10-04T23:36:15","date_gmt":"2020-10-04T15:36:15","guid":{"rendered":"http:\/\/4563.org\/?p=164312"},"modified":"2020-10-04T23:36:15","modified_gmt":"2020-10-04T15:36:15","slug":"%e5%85%b3%e4%ba%8e-golang-mongo-model-%e7%9a%84%e6%98%a0%e5%b0%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=164312","title":{"rendered":"\u5173\u4e8e golang mongo model \u7684\u6620\u5c04\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5173\u4e8e golang mongo model \u7684\u6620\u5c04\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chenqh <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4f7f\u7528\u7684\u5e93\u662f <code>https:\/\/github.com\/mongodb\/mongo-go-driver<\/code><\/p>\n<p>model \u5b9a\u4e49<\/p>\n<pre><code>type MUser struct {  Id        bson.ObjectId `bson:\"_id,omitempty\"`  CreateAt  int64         `bson: \"createtime\"`  IsRemoved int           `bson: \"hasremoved\"`  \/\/ \u767b\u5f55\u540d  Name string `bson: \"name\"`  \/\/ \u6635\u79f0  Nick string `bson: \"nick\"`  \/\/ \u5bc6\u7801  PassWord string `bson: \"password\"`  Role     string `bson: \"role\"`  Status   int    `bson: \"status\"` } <\/code><\/pre>\n<p>\u4e3a\u4ec0\u4e48\u63d2\u5165\u7684\u6570\u636e\u662f\u8fd9\u4e2a\u6837\u5b50\u7684\uff1f<\/p>\n<pre><code>{     \"_id\" : ObjectId(\"5f747b15dedcfdbb4c4ab599\"),     \"createat\" : NumberLong(1601469205),     \"isremoved\" : 0,     \"name\" : \"sample1\",     \"nick\" : \"nick\",     \"password\" : \"5f4dcc3b5aa765d61d8327deb882cf99\",     \"role\" : \"dev\",     \"status\" : 0 } <\/code><\/pre>\n<p>\u8bf7\u5927\u5bb6\u6307\u70b9\u4e00\u4e0b\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>7<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3597930\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jingniao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u95ee\u9898\u662f\u5565\uff1f\u54ea\u91cc\u4e0d\u7b26\u5408\u9884\u671f\u4e86\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3597931\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mason961125 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @jingniao #1 \u611f\u89c9\u4ed6\u60f3\u8bf4\u7684\u662f\u6307\u5b9a\u4e86 bson tag\uff0c\u4f46\u662f\u6ca1\u6309\u7167 tag value \u6765\u751f\u6210\u5b57\u6bb5\u540d&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3597932\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jingniao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u731c\u662f\u7a7a\u683c\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3597933\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : SingeeKing <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             #3 \u6b63\u89e3\uff0c\u5192\u53f7\u540e\u6709\u7a7a\u683c IDE \u90fd\u4f1a\u63d0\u793a\u7684\u624d\u5bf9                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3597934\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : chenqh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @SingeeKing \u8fd8\u771f\u7684\u662f\u8fd9\u6837\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3597935\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cloverzrg2 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u547d\u540d\u770b\u7740\u771f\u96be\u53d7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3597936\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : chenqh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @cloverzrg2 \u4f60\u662f\u8bf4\u540e\u9762\u7684 bson,\u540e\u9762\u7684 bson \u662f\u7279\u5730\u8be5\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e golang mongo m&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\/164312"}],"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=164312"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/164312\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=164312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=164312"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=164312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}