Mongo.getDB()
On this page本页内容
Description描述
Mongo.getDB(<database>)-
Provides access to database objects from提供从mongoshor from a JavaScript file.mongosh或JavaScript文件访问数据库对象的权限。TheMongo.getDB()method has the following parameter:Mongo.getDB()方法具有以下参数:Parameter参数Type类型Description描述databasestring The name of the database to access.要访问的数据库的名称。
Example实例
The following example instantiates a new connection to the MongoDB instance running on the localhost interface and returns a reference to 以下示例实例化了与本地主机接口上运行的MongoDB实例的新连接,并返回对"myDatabase":"myDatabase"的引用:
db = new Mongo().getDB("myDatabase");