cat()
| Returns the contents of the specified file返回指定文件的内容
fs.readFileSync( <filename>, 'utf8' )
The legacy useBinaryMode option is not supported. Emulate the useBinaryMode = false option with:不支持旧版useBinaryMode选项。使用以下命令模拟useBinaryMode = false选项:
fs.readFileSync( <filename>, 'utf8' ).replace( /\r\n/g, '\n' )
|
getHostName() | Returns the hostname of the system running mongosh.返回运行mongosh的系统的主机名。
os.hostname()
|
getMemInfo() | Returns a document that reports memory used by the shell.返回一个报告shell使用的内存的文档。
process.memoryUsage()
|
hostname() | Returns the hostname of the computer running the shell.返回运行shell的计算机的主机名。
os.hostname()
|
isInteractive() | Returns a boolean indicating whether mongosh is running in interactive or script mode.返回一个布尔值,指示mongosh是在交互模式还是脚本模式下运行。
isInteractive()
|
listFiles() | Returns an array of documents that give the name and type of each object in the directory.返回一个文档数组,其中给出了目录中每个对象的名称和类型。
fs.readdirSync( <path>, { withFileTypes: true } )
|
load() | Loads and runs a JavaScript file in the shell.在shell中加载并运行JavaScript文件。
load() is available in mongosh. See also Differences Between require() and load().load()在mongosh中可用。另请参见require()和load()之间的区别。
|
ls() | Returns a list of the files in the current directory.返回当前目录中的文件列表。
fs.readdirSync( <path> )
|
md5sumFile() | Returns the md5 hash of the specified file.返回指定文件的md5哈希值。
crypto.createHash( 'md5' ).update( fs.readFileSync( <filename> ) ).digest( 'hex' )
|
mkdir() | Creates a directory at the specified path.在指定路径创建目录。
fs.mkdirSync( <path>, { recursive: true } )
|
quit() | Exits the current shell session.退出当前shell会话。
quit()
|
removeFile() | Removes the specified file from the local file system.从本地文件系统中删除指定的文件。
fs.unlinkSync( <filename> )
|
sleep() | Sleep for the specified number of milliseconds.休眠指定的毫秒数。
sleep( <number> )
|
version() | Returns the current version of mongosh instance.返回mongosh实例的当前版本。
version()
|
_isWindows() | Returns true if the shell in running on Windows.如果shell在Windows上运行,则返回true。
process.platform === 'win32'
|
_rand() | Returns a random number between 0 and 1.返回一个介于0和1之间的随机数。
Math.random()
|