
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Manage tree structures in MongoDB
Install the module with: npm install mongotree
Create a default tree
var mongotree = require('mongotree'),
MongoClient = require('mongodb').MongoClient,
dsn = 'mongodb://localhost:27017/my-database';
// Create a new tree structure in a mongodb collection
MongoClient.connect(dsn, function(err, db) {
mongotree.addTree('products/cameras/accessories', db.collection('my-collection'), function(err, tree) {
console.log(tree);
db.close();
});
});
// outputs
[ { _id: 'products', name: 'products', parent: '' },
{ _id: 'products/cameras', name: 'cameras', parent: 'products' },
{ _id: 'products/cameras/accessories',
name: 'accessories',
parent: 'products/cameras' } ]
Create a tree with custom params for nodes
var params = {
path: 'products/cameras/accessories',
created: new Date()
};
mongotree.addTree(params, db.collection('my-collection'), function(err, tree) {
console.log(tree);
});
// outputs
[ { _id: 'products',
name: 'products',
parent: '',
created: Fri Aug 16 2013 09:41:44 GMT-0700 (MST) },
{ _id: 'products/cameras',
name: 'cameras',
parent: 'products',
created: Fri Aug 16 2013 09:41:44 GMT-0700 (MST) },
{ _id: 'products/cameras/accessories',
name: 'accessories',
parent: 'products/cameras',
created: Fri Aug 16 2013 09:41:44 GMT-0700 (MST) } ]
Create a tree with friendly path names
mongotree.addTree('Products / Cameras / Camera Accessories', collection, function(err, tree) {
console.log(tree);
});
// outputs
[ { _id: 'products',
name: 'Products',
parent: '' },
{ _id: 'products/cameras',
name: 'Cameras',
parent: 'products' },
{ _id: 'products/cameras/camera-accessories',
name: 'Camera Accessories',
parent: 'products/cameras' } ]
Get ancestors
mongotree.getAncestors('products/cameras/accessories', collection, function(err, tree) {
console.log(tree);
});
// outputs
[ { _id: 'products', name: 'products', parent: '' },
{ _id: 'products/cameras', name: 'cameras', parent: 'products' } ]
Get decendants
mongotree.getDecendants('products', collection, function(err, tree) {
console.log(tree);
});
// outputs
[ { _id: 'products/cameras', name: 'cameras', parent: 'products' },
{ _id: 'products/cameras/accessories',
name: 'accessories',
parent: 'products/cameras' } ]
FAQs
Manage tree structures in MongoDB
The npm package mongotree receives a total of 5 weekly downloads. As such, mongotree popularity was classified as not popular.
We found that mongotree 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.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.