On this page本页内容
Mongo.getDB(<database>) Provides access to database objects from 提供从mongosh or from a JavaScript file.mongosh或JavaScript文件访问数据库对象的权限。
The Mongo.getDB() method has the following parameter:Mongo.getDB()方法具有以下参数:
database | string |
The following example instantiates a new connection to the MongoDB instance running on the localhost interface and returns a reference to 以下示例实例化与在localhost接口上运行的MongoDB实例的新连接,并返回对"myDatabase":"myDatabase"的引用:
db = new Mongo().getDB("myDatabase");