Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
mongo-fixme
Advanced tools
Easy JSON fixture loading for MongoDB. Makes managing document relationships easier. This is a forked version of pow-mongodb-fixtures
This is a forked version of mongo-fixme
Simple fixture loader for MongoDB on NodeJS. Makes managing relationships between documents easier.
Fixtures can be in one file, or divided up into separate files for organisation (e.g. one file per model)
The fixture files must export objects which are keyed by the MongoDB collection name, each containing the data for documents within that.
FOR EXAMPLE: With the file below, 3 documents will be inserted into the 'users' collection and 2 into the 'businesses' collection:
//fixtures.js
exports.users = [
{ name: 'Gob' },
{ name: 'Buster' },
{ name: 'Steve Holt' }
];
exports.businesses = [
{ name: 'The Banana Stand' },
{ name: 'Bluth Homes' }
];
You can also load fixtures as an object where each document is keyed, in case you want to reference another document. This example uses the included createObjectId
helper:
//users.js
var id = require('mongo-fixme').createObjectId;
var users = exports.users = {
user1: {
_id: id(),
name: 'Michael'
},
user2: {
_id: id(),
name: 'George Michael',
father: users.user1._id
},
user3: {
_id: id('4ed2b809d7446b9a0e000014'),
name: 'Tobias'
}
}
A CLI program is included for quickly loading fixture files. To use it install the module globally:
npm install mongo-fixme -g
Then use the program to install a file or directory:
mongofixtures <dbname> <fixture file>
mongofixtures appdb fixtures/users.js
Returns a new Loader instance, configured to interact with a certain database.
Options:
Usage:
var fixtures = require('mongo-fixme').connect('dbname');
var fixtures2 = require('mongo-fixme').connect('dbname', {
host: 'http://dbhost.com/',
port: 1234
});
Adds documents to the relevant collection. If the collection doesn't exist it will be created first.
var fixtures = require('mongo-fixme').connect('mydb');
//Objects
fixtures.load({
users: [
{ name: 'Maeby' },
{ name: 'George Michael' }
]
}, callback);
//Files
fixtures.load(__dirname + '/fixtures/users.js', cb);
//Directories (loads all files in the directory)
fixtures.load(__dirname + '/fixtures', callback);
Clears existing data.
fixtures.clear(function(err) {
//Drops the database
});
fixtures.clear('foo', function(err) {
//Clears the 'foo' collection
});
fixtures.clear(['foo', 'bar'], function(err) {
//Clears the 'foo' and 'bar' collections
});
Drops the database (clear all collections) and loads data.
Clears the collections that have documents in the data
that is passed in, and then loads data.
var data = { users: [...] };
fixtures.clearAndLoad(data, function(err) {
//Clears only the 'users' collection then loads data
});
Adds a modifier (function) which gets called for each document that is to be inserted. The signature of this function should be:
(collectionName, document, callback)
Modifiers are chained in the order in which they're added. For example:
var data = { users: [...] };
// this modifier will get called first
fixtures.addModifier(function(collectionName, doc, cb) {
doc.createdAt = new Date();
cb(null, doc);
});
// this modifier will get called second with the result from the first modifier call
fixtures.addModifier(function(collectionName, doc, cb) {
doc.updatedAt = new Date();
cb(null, doc);
});
fixtures.load(data, function(err) {
// each loaded data item will have the createdAt and updatedAt keys set.
});
npm install mongo-fixme
###0.10.0
###0.10.0
###0.8.1
###0.7.1
###0.7.0
###0.6.4
###0.6.3
###0.6.2
###0.6.1
FAQs
Easy JSON fixture loading for MongoDB. Makes managing document relationships easier. This is a forked version of pow-mongodb-fixtures
The npm package mongo-fixme receives a total of 1 weekly downloads. As such, mongo-fixme popularity was classified as not popular.
We found that mongo-fixme 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.