
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@joshdb/mongo
Advanced tools
The MongoDB provider uses the mongodb module for persistent storage of JOSH data.
The installation of the mongodb module is fairly straightforward and does not have any pre-requisites.
However, you must ensure that you have an available MongoDB server running. josh-mongo does not automatically create a server for you!
If you don't know, or don't want, to host a Mongo DB server instance, you can create a free one on MongoDB Atlas. See specific instructions below for that service.
In your project folder, you should be able to install using this command:
npm i @joshdb/mongo
** OR **
yarn add @joshdb/mongo
Using the mongo provider goes as such:
const Josh = require('@joshdb/core');
const JoshMongo = require('@joshdb/mongo');
const db = new Josh({
name: 'testing',
provider: JoshMongo,
// See below for all provider options.
providerOptions: {
collection: 'testing',
dbName: "yourclustername",
url: "mongodb+srv://<username>:<password>@cluster0.0zbvd.mongodb.net/<dbName>?retryWrites=true&w=majority"
}
});
db.defer.then( async () => {
console.log(`Connected, there are ${await db.size} rows in the database.`);
});
Let's try to make some sense of the options. In the above example I use the URL for the connection, using a Mongo Atlas cluster.
Here is a list of full options this provider supports:
| Param | Type | Description |
|---|---|---|
| [providerOptions] | Object | The Provider Options Object, with the below properties: |
| [providerOptions.collection] | string | Required. The name of the collection in which to save the data. |
| [providerOptions.dbName] | string | Optional, defaults to josh. The name of the database to which collections are written. |
| [providerOptions.user] | string | Optional if not using a URL. The username for the mongodb connection. |
| [providerOptions.password] | string | Optional if not using a URL. The password for the mongodb connection. |
| [providerOptions.port] | string | Optional, defaults to 27017. The port where mongodb is hosted. |
| [providerOptions.host] | string | Optional, defaults to localhost. The host/machine/URL where the mongodb connection is located. Should never be an HTTP address! |
| [providerOptions.url] | string | Optional, single-line configuration. If used, ignores all other options except options.collection, and requires the full connection string to access the database, including the database name |
Mongo Atlas is a free mongodb hosting service made by, if that wasn't obvious, the Mongo people. While there are some limitations to the free service, it's still very useable for any small implementation.
The setup for Mongo Atlas goes something like this:
guidebot-cluster.guidebot-session then a collection name such as sessions.FAQs
MongoDB Provider for JOSH
We found that @joshdb/mongo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.