午夜无码人妻aⅴ大片色欲张津瑜,国产69久久久欧美黑人A片,色妺妺视频网,久久久久国产综合AV天堂

mongoshell啟動配置文件.mongorc.js(三)

mongo shell啟動配置文件.mongorc.js(三)

成都創(chuàng)新互聯(lián)專注于企業(yè)營銷型網(wǎng)站、網(wǎng)站重做改版、潮陽網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、html5、商城網(wǎng)站定制開發(fā)、集團公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為潮陽等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。

自定義MongoDB操作函數(shù)

可以把自己寫的js代碼保存在某個地方,讓MongoDB加載它,然后就可以在MongoDB的命令行里操作它們。

mongodb shell默認(rèn)會加載~/.mongorc.js文件

例如以下修改了啟動提示文字、左側(cè)提示文字,增加了my_show_shards shell函數(shù)用于顯示當(dāng)前sharded collection的chunks在各分片的負(fù)載情況:

//~/.mongorc.js  
//show at begin    
var compliment = ["attractive", "intelligent", "like batman"];    
var index = Math.floor(Math.random()*3);    
print("Hello, you're looking particularly " + compliment[index] + " today!");
//change the prompt    
prompt = function(){    
    if (typeof db == "undefined") {    
        return "(nodb)> ";    
    }    
    // Check the last db operation    
    try {    
        db.runCommand({getLastError: 1});    
    }    
    catch (e) {    
        print(e);    
    }    
    return db + "> ";    
}
//show all shard's chunks    
function my_show_shards() {    
    var config_db = db.getSiblingDB("config");    
    var collections = {};    
    var shards = {};    
    var shard_it = config_db.chunks.find().snapshot();
    while (shard_it.hasNext()) {  
        next_item = shard_it.next();    
        collections[JSON.stringify(next_item["ns"]).replace(/\"/g, "")] = 1;    
        shards[JSON.stringify(next_item["shard"]).replace(/\"/g, "")] = 1;    
    }    
    var list_collections = [];    
    var list_shards = [];    
    for (item in collections) {    
        list_collections.push(item);    
    }    
    for (item in shards) {    
        list_shards.push(item);    
    }
    list_collections.forEach(function(collec) {  
            list_shards.forEach(function(item) {    
                obj = {};    
                obj["shard"] = item;    
                obj["ns"] = collec;    
                it = config_db.chunks.find(obj);    
                print(collec, item, it.count());    
                })    
            })    
}

當(dāng)前標(biāo)題:mongoshell啟動配置文件.mongorc.js(三)
本文來源:http://www.ekvhdxd.cn/article4/psgcoe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗、面包屑導(dǎo)航、服務(wù)器托管微信小程序、Google手機網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)