
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
catbox-mongodb-yalo
Advanced tools
MongoDB adapter for catbox
Note: the module has been deprecated and archived due to low usage. The last publish version is known it work well but that may change in the future as breaking changes of catbox are introduced. If you rely on this module, consider forking it and creating your own alternative (it is very little code). You can also ask to take over and the module will be moved to your personal account to maintain.
catbox-mongodb serializes values to BSON using MongoDB driver, therefore following data types are supported for this adapter: Object, Array, Number, String, Date, RegExp.
The lastest
catbox-mongodb
version4.x
works only with hapi v17 and v18
Install catbox-mongodb
via NPM. Remember that catbox-mongodb
requires its parent module catbox
:
npm install catbox catbox-mongodb
Do you use hapi v16 or lower? Install catbox-mongodb
version 3.x
with a compatible version of catbox
:
# for hapi v16 (or lower)
npm install catbox@9 catbox-mongodb@3
catbox-mongodb
accepts the following options:
uri
- the MongoDB URI, defaults to 'mongodb://127.0.0.1:27017/?maxPoolSize=5'
partition
- the MongoDB database for cached itemsSample catbox cache initialization :
const Catbox = require('catbox');
const cache = new Catbox.Client(require('catbox-mongodb'), {
uri: 'your-mongodb-uri', // Defaults to 'mongodb://127.0.0.1:27017/?maxPoolSize=5'
partition: 'cache-users'
})
Or configure your hapi server to use catbox-mongodb
as the caching strategy (code snippet uses hapi v17
):
const Hapi = require('hapi')
const server = new Hapi.Server({
cache : [{
name: 'mongodb-cache',
engine: require('catbox-mongodb'),
uri: 'your-mongodb-uri', // Defaults to 'mongodb://127.0.0.1:27017/?maxPoolSize=5'
partition: 'cache-posts'
}]
});
For hapi v18
you need a slightly different config:
const Hapi = require('hapi')
const server = new Hapi.Server({
cache : [{
name: 'mongodb-cache',
provider: {
constructor: require('catbox-mongodb'),
options: {
uri : 'your-mongodb-uri', // Defaults to 'mongodb://127.0.0.1:27017/?maxPoolSize=5'
partition : 'cache'
}
}
}]
});
FAQs
MongoDB adapter for catbox
We found that catbox-mongodb-yalo 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
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.