This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a ZSTD Collection | |
db.createCollection("COLLNAME", {storageEngine: {wiredTiger: {configString: "block_compressor=zstd"}}}) | |
// Check which block compressor is being used for a collection | |
var wt_options = db.zlogs.stats().wiredTiger.creationString.split(',') | |
// filter the options | |
wt_options.filter((wt_options) => wt_options.startsWith('block_compressor')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2020 Kuei-chun Chen. All rights reserved. | |
var cluster = GetClustersSummary() | |
var data = JSON.stringify(cluster); | |
print(data); | |
function GetClustersSummary() { | |
var cluster = { "cluster": "standalone", "databases": [], | |
"keyhole": { "version": "v2.5.0-js", "collected": new Date(), "logs": [] } }; | |
cluster["keyhole"]["logs"].push(new Date().toISOString()+" keyhole.js began"); | |
var doc = db.serverStatus(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MongoClient = require("mongodb").MongoClient; | |
const util = require('util') | |
const MONGOURI = "MONGOURL"; | |
const DB = "lever-hire-nurture"; | |
const COLL = "profiles"; | |
const client = new MongoClient(MONGOURI, { useNewUrlParser: true, useUnifiedTopology: true }); | |
client.connect(err => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ClientEncryption } = require('mongodb-client-encryption'); | |
const base64 = require('uuid-base64'); | |
const mongoose = require('mongoose'); | |
// DONOT USE IN PRODUCTION | |
function getEncryptionKey() { | |
const arr = []; | |
for (let i = 0; i < 96; ++i) { | |
arr.push(i); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rl = require("readline"); | |
const FILEPATH = "/Users/Karan.Srivastava/Desktop/Manish Sahni/s1.log"; | |
const OUTPUTFILE = "s1k.log"; | |
const lineReader = rl.createInterface({ | |
input: require("fs").createReadStream(require("path").normalize(FILEPATH)) | |
}) | |
let prevLine = ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var colls = db.getCollectionNames(); | |
var ret = []; | |
colls.forEach(function(coll) { | |
if (String(coll).startsWith("system")) { | |
return; | |
} | |
var indexes = db.getCollection(coll).getIndexes(); | |
var stats = db.getCollection(coll).aggregate( [ { $indexStats: { } } ] ).toArray(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var colls = db.getCollectionNames(); | |
var ret = []; | |
colls.forEach(function(coll) { | |
if (String(coll).startsWith("system")) { | |
return; | |
} | |
var indexes = db.getCollection(coll).getIndexes(); | |
var stats = db.getCollection(coll).aggregate( [ { $indexStats: { } } ] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var objectIdFromDate = function (date) { | |
return Math.floor(date.getTime() / 1000).toString(16) + "0000000000000000"; | |
}; | |
var dateFromObjectId = function (objectId) { | |
return new Date(parseInt(objectId.substring(0, 8), 16) * 1000); | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var colls = db.getCollectionNames(); | |
var ret = []; | |
colls.forEach(function(coll) { | |
var indexes = db.getCollection(coll).getIndexes(); | |
var len = indexes.length | |
ret.push({ "name": coll, "length": len }); | |
}) | |
printjson(ret) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Simple demonstration using MongoDB Client-Side Field Level Encryption (local key version) | |
Requires Community or (preferrably) Enterprise Shell and a MongoDB 4.2+ database | |
Local, stand-alone, or Atlas MongoDB will all work. | |
To use this, just open Mongo shell, with this file, e.g.: | |
mongo --nodb --shell hello_world_shell_local.js | |
# For a self-signed cert: mongo --tls --tlsCAFile /opt/mongodb/certs/ca.pem --shell hello_world_shell_local.js |
NewerOlder