
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@sachin-chourasiya/mongoose-aggregation-builder
Advanced tools
A secure, chainable MongoDB aggregation builder for Mongoose with input validation and safe defaults.
A simple, secure, and chainable MongoDB aggregation pipeline builder for Mongoose.
It makes complex aggregation queries easier to write, readable, and safe from injection risks.
Writing raw MongoDB aggregation pipelines can be verbose and hard to maintain:
User.aggregate([
{ $match: { status: 'active' } },
{
$lookup: {
from: 'orders',
localField: '_id',
foreignField: 'userId',
as: 'orders',
},
},
{ $unwind: { path: '$orders', preserveNullAndEmptyArrays: true } },
{ $group: { _id: '$_id', totalOrders: { $sum: 1 } } },
{ $sort: { totalOrders: -1 } },
{ $limit: 10 },
]);
With @sachin-chourasiya/mongoose-aggregation-builder:
const pipeline = Agg()
.filter({ status: 'active' })
.join('orders', '_id', 'userId', 'orders')
.unwind('orders', true)
.countOrders()
.sortBy('totalOrders', 'desc')
.limit(10)
.build();
User.aggregate(pipeline);
npm install @sachin-chourasiya/mongoose-aggregation-builder
.d.ts
type definitions (coming soon)const Agg = require('@sachin-chourasiya/mongoose-aggregation-builder');
const pipeline = Agg()
.filter({ isActive: true })
.project({ name: 1, email: 1 })
.build();
User.aggregate(pipeline);
Generated Pipeline:
[{ $match: { isActive: true } }, { $project: { name: 1, email: 1 } }];
const pipeline = Agg()
.filter({ status: 'active' })
.join('orders', '_id', 'userId', 'orders')
.unwind('orders')
.build();
User.aggregate(pipeline);
Generated Pipeline:
[
{ $match: { status: 'active' } },
{
$lookup: {
from: 'orders',
localField: '_id',
foreignField: 'userId',
as: 'orders',
},
},
{ $unwind: '$orders' },
];
const pipeline = Agg()
.filter({ status: 'active' })
.groupBy('_id', { totalOrders: { $sum: 1 } })
.sortBy('totalOrders', 'desc')
.limit(5)
.build();
User.aggregate(pipeline);
$
operator injection in keys.filter(query)
Adds a $match
stage to filter documents.
.project(fields)
Adds a $project
stage.
.join(collection, localField, foreignField, as)
Adds a $lookup
stage to join another collection.
.unwind(path, preserveNull = false)
Adds a $unwind
stage.
.groupBy(id, accumulators)
Adds a $group
stage.
.countOrders()
Custom helper → counts number of joined documents.
.sortBy(field, order = "asc")
Adds a $sort
stage.
.limit(n)
Adds a $limit
stage.
.build()
Returns the final aggregation pipeline array.
MIT License © 2025
FAQs
A secure, chainable MongoDB aggregation builder for Mongoose with input validation and safe defaults.
We found that @sachin-chourasiya/mongoose-aggregation-builder 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.