{"id":319968,"date":"2021-02-05T11:05:49","date_gmt":"2021-02-05T03:05:49","guid":{"rendered":"http:\/\/4563.org\/?p=319968"},"modified":"2021-02-05T11:05:49","modified_gmt":"2021-02-05T03:05:49","slug":"%e8%ae%be%e7%bd%ae%e4%ba%86-db-prototype-dropdatabase-%e4%b8%ba-no%ef%bc%8c%e4%b8%ba%e4%bb%80%e4%b9%88%e8%bf%98%e8%a6%81%e8%ae%be%e7%bd%ae-db-dropdatabase-%e5%91%a2%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=319968","title":{"rendered":"\u8bbe\u7f6e\u4e86 DB.prototype.dropDatabase \u4e3a no\uff0c\u4e3a\u4ec0\u4e48\u8fd8\u8981\u8bbe\u7f6e db.dropDatabase \u5462\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bbe\u7f6e\u4e86 DB.prototype.dropDatabase \u4e3a no\uff0c\u4e3a\u4ec0\u4e48\u8fd8\u8981\u8bbe\u7f6e db.dropDatabase \u5462\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5728<em>MongoDB: The Definitive Guide, 3rd Edition &#8211; 2. Getting Started &#8211; Using the MongoDB Shell &#8211; Creating a .mongorc.js<\/em>\u4e2d\uff0c\u6709\u4e0b\u9762\u8fd9\u4e48\u4e00\u6bb5\uff1a<\/p>\n<blockquote>\n<p>More practically, you can use this script to set up any global variables you\u2019d like to use, alias long names to shorter ones, and override built-in functions. One of the most common uses for <em>.mongorc.js<\/em> is remove some of the more \u201cdangerous\u201d shell helpers. You can override functions like <code>dropDatabase<\/code> or <code>deleteIndexes<\/code> with no-ops or undefine them altogether:<\/p>\n<pre><code>db.dropDatabase = DB.prototype.dropDatabase = no; <\/code><\/pre>\n<p>Make sure that, if you change any database functions, you do so on both the db variable and the DB prototype (as shown in the example above). If you change only one, either the db variable won\u2019t see the change or all new databases you use (when you run use anotherDB) won\u2019t see your change.<\/p>\n<\/blockquote>\n<p>db.dropDatabase \u662f\u6765\u6e90\u4e8e DB.prototype.dropDatabase \u7684\uff0c\u8bbe\u7f6e\u4e86 DB.prototype.dropDatabase \u4e3a no\uff0c\u4e3a\u4ec0\u4e48\u8fd8\u8981\u8bbe\u7f6e db.dropDatabase \u5462\uff1f\u6211\u81ea\u5df1\u505a\u4e86\u5b9e\u9a8c\uff0c\u53ea\u9700\u8981\u201c\u8bbe\u7f6e DB.prototype.dropDatabase \u4e3a no\u201d\u5c31\u53ef\u4ee5\u4e86\uff0c\u662f\u8fd8\u6709\u5176\u5b83\u6211\u4e0d\u77e5\u9053\u7684\u4e1c\u897f\u5417\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bbe\u7f6e\u4e86 DB.prototype.&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\/319968"}],"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=319968"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/319968\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319968"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}