Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
mongoose-to-csv
Advanced tools
MongooseToCsv is a mongoose plugin that creates a CsvBuilder
instance for your Schema.
var UserSchema = new mongoose.Schema({
fullname: {type: String},
email: {type: String},
age: {type: Number},
username: {type: String}
});
UserSchema.plugin(mongooseToCsv, {
headers: 'Firstname Lastname Username Email Age',
constraints: {
'Username': 'username',
'Email': 'email',
'Age': 'age'
},
virtuals: {
'Firstname': function(doc) {
return doc.fullname.split(' ')[0];
},
'Lastname': function(doc) {
return doc.fullname.split(' ')[1];
}
}
});
var User = mongoose.model('Users', UserSchema);
// Query and stream
User.findAndStreamCsv({age: {$lt: 40}})
.pipe(fs.createWriteStream('users_under_40.csv'));
// Create stream from query results
User.find({}).exec()
.then(function(docs) {
User.csvReadStream(docs)
.pipe(fs.createWriteStream('users.csv'));
});
// Transform mongoose streams
User.find({})
.where('age').gt(20).lt(30)
.limit(10)
.sort('age')
.stream()
.pipe(User.csvTransformStream())
.pipe(fs.createWriteStream('users.csv'));
$ npm install mongoose-to-csv
Running tests requires a local mongodb server, and mocha. While most likely not a namespace issue, the test script will create a database __mongoose_to_csv_test__
, and drop the database when finished. You have been warned.
$ npm test
The options
argument is passed to the CsvBuilder
instance, please refer to
the Docs for more in-depth details. The only aditional property that can be included is the virutals
property.
The virtuals
have nothing to do with mongoose virtuals.
Creates a csv formated read stream from query results.
Transforms mongoose querystreams to csv formated streams.
Schema.find(query).stream().pipe(Schema.csvTransformStream())
FAQs
Export mongoose querys as csv streams.
The npm package mongoose-to-csv receives a total of 938 weekly downloads. As such, mongoose-to-csv popularity was classified as not popular.
We found that mongoose-to-csv 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.