When writing MongoDB queries, JSHint warnings and errors were becoming noise, so I created a .jshintrc specialized for MongoDB that I’d like to introduce.
If you want a .jshintrc specialized for MongoDB, please download it from the following URL.
In the mongo shell, if you press the tab key after entering a half-width space or dash, all methods and classes will be displayed in a list.
Display all 185 possibilities? (y or n)
Array( Random( create isSealed run(
BinData( RegExp( createMongoArgs( isString( runMongoProgram(
Boolean( ReplSetBridge( db jsTest runProgram(
BulkWriteError( ReplSetTest( decodeURI( jsTestFile( seal
BulkWriteResult( ReplTest( decodeURIComponent( jsTestLog( setJsTestOption(
CountDownLatch ShardingTest( defaultPrompt( jsTestName( setVerboseShell(
DB( String( defineProperties jsTestOptions( sh(
DBCollection( SyncCCTest( defineProperty jsTestPath( shellAutocomplete(
DBCommandCursor( TestData doassert( keys shellHelper(
DBExplainQuery( Timestamp( encodeURI( listFiles( shellPrint(
DBPointer( ToolTest( encodeURIComponent( load( shellPrintHelper(
DBQuery( UUID( escape( ls( sleep(
DBRef( WriteCommandError( eval( md5sumFile( sortDoc(
Date( WriteConcern( false mkdir( startMongoProgram(
Explainable( WriteResult( freeze module startMongoProgramNoConnect(
Geo allocatePorts( friendlyEqual( myPort( startMongod(
HexData( argumentsToArray( gc( null startMongodEmpty(
ISODate( assert( getActiveCommands( parseFloat( startMongodNoReset(
Infinity authutil getBuildInfo( parseInt( startMongodTest(
JSON benchFinish( getHostName( pathExists( startMongos(
MD5( benchRun( getMemInfo( preventExtensions startParallelShell(
MR benchRunSync( getOwnPropertyDescriptor print( stopMongoProgram(
Map( benchStart( getOwnPropertyNames printShardingSizes( stopMongoProgramByPid(
MapReduceResult( bsonWoCompare( getPrototypeOf printShardingStatus( stopMongod(
Math bsonsize hasOwnProperty( printStackTrace( testingReplication
MaxKey cat( help( printjson( toLocaleString(
MinKey cd( hex_md5( printjsononeline( toString(
Mongo( chatty( hostname( propertyIsEnumerable( tojson(
MongoRunner( checkProgram( interpreterVersion( prototype tojsonObject(
MongodRunner( clearRawMongoProgramOutput( isExtensible pwd( tojsononeline(
NaN compare( isFinite( quit( true
Number( compareOn( isFrozen rawMongoProgramOutput( undefined
NumberInt( connect( isKeyTooLarge( reconnect( unescape(
NumberLong( connectionURLTheSame( isMasterStatePrompt( removeFile( validateIndexKey(
ObjectId( constructor isNaN( replSetMemberStatePrompt( valueOf(
PlanCache( copyDbpath( isNumber( resetDbpath( version(
QueryPlan( copyFile( isObject( rs( waitProgram(
You can also view this in the official MongoDB manual, but formatting the shell output is easier.
You can quickly format it using rectangular selection. The list is as follows.
Below is a list of methods formatted in JSON format.
"Array",
"BinData",
"Boolean",
"BulkWriteError",
"BulkWriteResult",
"CountDownLatch",
"DB",
"DBCollection",
"DBCommandCursor",
"DBExplainQuery",
"DBPointer",
"DBQuery",
"DBRef",
"Date",
"Explainable",
"Geo",
"HexData",
"ISODate",
"Infinity",
"JSON",
"MD5",
"MR",
"Map",
"MapReduceResult",
"Math",
"MaxKey",
"MinKey",
"Mongo",
"MongoRunner",
"MongodRunner",
"NaN",
"Number",
"NumberInt",
"NumberLong",
"ObjectId",
"PlanCache",
"QueryPlan",
"Random",
"RegExp",
"ReplSetBridge",
"ReplSetTest",
"ReplTest",
"ShardingTest",
"String",
"SyncCCTest",
"TestData",
"Timestamp",
"ToolTest",
"UUID",
"WriteCommandError",
"WriteConcern",
"WriteResult",
"allocatePorts",
"argumentsToArray",
"assert",
"authutil",
"benchFinish",
"benchRun",
"benchRunSync",
"benchStart",
"bsonWoCompare",
"bsonsize",
"cat",
"cd",
"chatty",
"checkProgram",
"clearRawMongoProgramOutput",
"compare",
"compareOn",
"connect",
"connectionURLTheSame",
"constructor",
"copyDbpath",
"copyFile",
"create",
"createMongoArgs",
"db",
"decodeURI",
"decodeURIComponent",
"defaultPrompt",
"defineProperties",
"defineProperty",
"doassert",
"encodeURI",
"encodeURIComponent",
"escape",
"eval",
"false",
"freeze",
"friendlyEqual",
"gc",
"getActiveCommands",
"getBuildInfo",
"getHostName",
"getMemInfo",
"getOwnPropertyDescriptor",
"getOwnPropertyNames",
"getPrototypeOf",
"hasOwnProperty",
"help",
"hex_md5",
"hostname",
"interpreterVersion",
"isExtensible",
"isFinite",
"isFrozen",
"isKeyTooLarge",
"isMasterStatePrompt",
"isNaN",
"isNumber",
"isObject",
"isSealed",
"isString",
"jsTest",
"jsTestFile",
"jsTestLog",
"jsTestName",
"jsTestOptions",
"jsTestPath",
"keys",
"listFiles",
"load",
"ls",
"md5sumFile",
"mkdir",
"module",
"myPort",
"null",
"parseFloat",
"parseInt",
"pathExists",
"preventExtensions",
"print",
"printShardingSizes",
"printShardingStatus",
"printStackTrace",
"printjson",
"printjsononeline",
"propertyIsEnumerable",
"prototype",
"pwd",
"quit",
"rawMongoProgramOutput",
"reconnect",
"removeFile",
"replSetMemberStatePrompt",
"resetDbpath",
"rs",
"run",
"runMongoProgram",
"runProgram",
"seal",
"setJsTestOption",
"setVerboseShell",
"sh",
"shellAutocomplete",
"shellHelper",
"shellPrint",
"shellPrintHelper",
"sleep",
"sortDoc",
"startMongoProgram",
"startMongoProgramNoConnect",
"startMongod",
"startMongodEmpty",
"startMongodNoReset",
"startMongodTest",
"startMongos",
"startParallelShell",
"stopMongoProgram",
"stopMongoProgramByPid",
"stopMongod",
"testingReplication",
"toLocaleString",
"toString",
"tojson",
"tojsonObject",
"tojsononeline",
"true",
"undefined",
"unescape",
"validateIndexKey",
"valueOf",
"version",
"waitProgram",
When you’re seriously developing MongoDB queries with JavaScript files managed in a Git repository, having a .jshintrc should improve your query creation workflow.
That’s all from the Gemba.