
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
mongodb-extended
Advanced tools
Extends the node.js MongoDB driver providing useful tools for keeping database and collection settings in sync.
Extends the Node.js driver adding a useful API for modeling MongoDB objects and keeping database structures in sync across environments.
Use case:
When using MongoDB without a tool like Mongoose, it can be burdensome and problematic to maintain indexes, schemas, etc. across environments.
This module provides a mechanism for configuring your MongoDB collections in code and keeping things in sync across multiple environments.
MongoDB driver version:
With mongodb-extended, your application can configure each collection as necessary and mongodb-extended will keep the database in sync with your configuration.
This includes:
With NPM:
npm i mongodb-extended
With Yarn:
yarn add mongodb-extended
Promise
Connect to MongoDB and optionally initialize the database configuration and collections.
Returns: Promise
- Resolves an objecting the MongoDB client, db, and
collections.
Param | Type | Default | Description |
---|---|---|---|
dbConf | Configuration | Full configuration. See the type definition for details. | |
[options] | object | Run-time options. | |
[options.initialize] | boolean | false | Whether to initialize the db and collections. |
[options.concurrency] | number | Override the concurrency for all relevant operations. |
Example (Basic connection.)
const connect = require('mongodb-extended');
connect({
collections: {
myCollection: {
indexes: {
name: { keys: { name: 1 }, options: { unique: true } },
},
// MongoDB collection options. Providing a simple schema validator.
options: {
validator: {
$jsonSchema: {
required: ['name', 'value'],
properties: {
name: { type: 'string' },
value: { type: 'string|number' },
},
},
},
},
// Pre-populate our db with data
data: [
{ name: 'foo', value: 'bar' },
{ name: 'abc', value: 123 },
],
// Ensure old indexes that are no longer used are removed
dropIndexes: [
'legacyIndex1',
'legacyIndex2',
],
},
myView: {
options: {
viewOn: 'myCollection',
pipeline: [
{ $group: { _id: '$value', names: { $addToSet: '$name' } } },
{ $sort: { _id: -1 } },
],
},
},
},
// Ensure old collections that are no longer used are removed.
dropCollections: [
'legacyCollection1',
'legacyCollection2',
],
// Syncronize the database server parameters with the parameters specified
// here. WARNING: These settings affect the entire database server.
serverParameters: {
notablescan: true,
},
// This initialize flag triggers the initialization operations. When true
// server parameters and collection settings are synchonized with the
// database.
}, { initialize: true }).then(({ client, collections }) => {
collections.foo.findOne({ name: 'bar' })
.then((document) => {
console.log(document);
client.close();
})
.catch((e) => {
client.close();
console.error(e);
});
});
Promise
Promise
Promise
Promise
Promise
object
Promise
string
| number
object
Promise
Promise
object
Promise.<InitializeCollectionsResult>
Promise
object
Promise
Connect to mongodb with extended configuration options.
Kind: static property of connect
Returns: Promise
- Resolves an object containing the client, db, and
collections.
Param | Type | Description |
---|---|---|
conf | object | Extended database configuration. |
Promise
Connect and initialize (sync database and collection settings).
Kind: static property of connect
Returns: Promise
- Resolves an object containing the MongoDB client, db,
and an object with each configured collection.
Param | Type | Description |
---|---|---|
conf | Configuration | Full database and collection configuration. |
Promise
Ensure collections do not exist. If a provided collection exists, it will be dropped.
Kind: static property of connect
Returns: Promise
- Resolves an array of collection names that existed and
were dropped.
Param | Type | Description |
---|---|---|
db | module:c |
FAQs
Extends the node.js MongoDB driver providing useful tools for keeping database and collection settings in sync.
The npm package mongodb-extended receives a total of 11 weekly downloads. As such, mongodb-extended popularity was classified as not popular.
We found that mongodb-extended demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.