{"id":438586,"date":"2021-04-14T10:58:20","date_gmt":"2021-04-14T02:58:20","guid":{"rendered":"http:\/\/4563.org\/?p=438586"},"modified":"2021-04-14T10:58:20","modified_gmt":"2021-04-14T02:58:20","slug":"mongodb-%e4%b8%ad-listfield-%e7%9a%84-%e8%87%aa%e5%ae%9a%e4%b9%89%e9%a1%ba%e5%ba%8f%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=438586","title":{"rendered":"mongodb \u4e2d ListField \u7684 \u81ea\u5b9a\u4e49\u987a\u5e8f\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  mongodb \u4e2d ListField \u7684 \u81ea\u5b9a\u4e49\u987a\u5e8f\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : among <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>class Test_TC(Document):     meta = {'collection': 'Test_TC', 'strict': False}     name = StringField()  class Test_TS(Document):     meta = {'collection': 'Test_TS', 'strict': False}     name = StringField()     # \u5217\u8868     tc_list = ListField(ReferenceField(Test_TC, reverse_delete_rule=PULL))      <\/code><\/pre>\n<p>\u5728 tc_list \u4e2d\u5b58\u50a8\u7684\u662f\u4e00\u4e2a list\uff0c\u5982\u4f55\u6765\u8bbe\u5b9a\u91cc\u9762\u7684 list \u7684\u987a\u5e8f\u3002<\/p>\n<p>\u539f\u59cb\u9700\u6c42\u662f\uff0c\u5728 Test_TS \u5b58\u50a8 \u4e00\u4e2a\u81ea\u5b9a\u4e49\u987a\u5e8f\u7684 list\uff0c\u5173\u8054\u5230 Test_TC \u3002 \u5f00\u59cb\u7684\u65f6\u5019\uff0c\u4f7f\u7528 push \u53ef\u4ee5\u6709\u6307\u5b9a\u5230 index.<\/p>\n<p>\u4f46\u662f\u540e\u7eed\u4f1a\u6709\u5728\u524d\u7aef\u8fdb\u884c \u62d6\u62c9\u7684\u52a8\u4f5c\uff0c\u8c03\u6574\u987a\u5e8f\uff0c\u5982\u4f55\u5b9e\u73b0\u8fd9\u4e2a\u987a\u5e8f\u8c03\u6574\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5750133\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : maocat <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4eec\u7684\u505a\u6cd5\uff0c\u524d\u7aef\u628a id \u6392\u597d\u987a\u5e8f\uff0c\u540e\u7aef\u91cd\u65b0\u5199\u5165 List                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750134\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : felixin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u52a0\u4e2a position\uff1aint\uff0c\u62d6\u52a8\u6539\u4f4d\u7f6e\uff0c\u524d\u7aef\u5c55\u793a\u524d\u6392\u5e8f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5750135\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ch2 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u62d6\u52a8\u6392\u5e8f\uff0c\u4e00\u822c\u662f\u7ed9\u6bcf\u4e2a key \u4e00\u4e2a\u521d\u59cb\u7684\u6d6e\u70b9\u6570\u4f18\u5148\u7ea7 pri \u4fdd\u8bc1\u9012\u589e\u6216\u8005\u9012\u51cf\uff0c\u628a E \u62d6\u5230 AB \u4e4b\u95f4\u5c31\u662f\u66f4\u65b0 preE=(priA+priB)\/2\uff0c\u800c\u4e0d\u662f\u6bcf\u6b21\u628a\u4e00\u4e2a list \u4f20\u8fc7\u53bb\u518d\u8fd4\u56de\u6765\u5b58\u5230\u6570\u636e\u5e93\u91cc                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>mongodb \u4e2d ListFie&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\/438586"}],"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=438586"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/438586\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=438586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=438586"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=438586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}