hardhat-mongodb
This plug-in it is used to add a mongodb db instance to the hardhat runtime environment.
Hardhat mongodb plugin.
What
This plugin will help you with the usage of a mongodb database in your hardhat's projects.
Installation
npm install @sebasgoldberg/hardhat-mongodb
Import the plugin in your hardhat.config.js
:
require("@sebasgoldberg/hardhat-mongodb");
Or if you are using TypeScript, in your hardhat.config.ts
:
import "@sebasgoldberg/hardhat-mongodb";
Environment extensions
This plugin extends the Hardhat Runtime Environment by adding a mongodb
field.
Here is an example to get the mongodb db:
// ...
const db = await this.hre.mongodb.getDb()
// ...
Configuration
Here is the optional configuration of this plugin:
const config: HardhatUserConfig = {
// ...
mongodb: {
dbConnectionString: 'mongodb://localhost:27017',
dbName: 'hardhat'
}
// ...
}
The example above, shows the default configuration values.