
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.
mongoose-maestro
Advanced tools
A powerful and elegant MongoDB/Mongoose toolkit that makes database operations a breeze with built-in performance monitoring, model management, and pagination
A simple and powerful MongoDB wrapper for Node.js that makes working with MongoDB/Mongoose easier and more intuitive.
npm install mongoose-maestro
const mongoose = require('mongoose');
const EasyMongo = require('mongoose-maestro');
// Define your mongoose schema
const userSchema = new mongoose.Schema({
name: String,
email: String,
age: Number
});
// Create model
const UserModel = mongoose.model('User', userSchema);
// Initialize Easy-Mongo with advanced features
const userDb = new EasyMongo(UserModel, {
enableCache: true, // Enable caching
cacheTTL: 3600, // Cache TTL in seconds
enableRateLimit: true, // Enable rate limiting
rateLimit: { // Rate limit options
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100 // Limit each IP to 100 requests per windowMs
},
enablePerformanceMonitoring: true // Enable performance monitoring
});
// Connect to MongoDB
await EasyMongo.connect('mongodb://localhost:27017/mydb');
// Create
const user = await userDb.create({
name: 'John Doe',
email: 'john@example.com',
age: 30
});
// Create Multiple
const users = await userDb.createMany([
{ name: 'Alice', age: 25 },
{ name: 'Bob', age: 35 }
]);
// Find by ID
const user = await userDb.findById('user_id');
// Find One
const user = await userDb.findOne({ email: 'john@example.com' });
// Find Many with Options
const users = await userDb.find(
{ age: { $gt: 18 } }, // filter
{
select: 'name email', // fields to select
sort: { name: 1 }, // sorting
skip: 0, // pagination
limit: 10, // limit results
populate: 'posts' // populate relations
}
);
// Update
await userDb.update(
{ email: 'john@example.com' }, // filter
{ age: 31 } // update data
);
// Update by ID
await userDb.updateById('user_id', { age: 31 });
// Delete
await userDb.delete({ email: 'john@example.com' });
// Delete by ID
await userDb.deleteById('user_id');
// Chainable Query Builder
const activeUsers = await userDb
.query()
.where({ status: 'active' })
.select('name email')
.sort('-createdAt')
.limit(10)
.execute();
// Large Dataset Query Builder with Streaming
const userStream = await userDb
.largeDataset()
.where({ age: { $gt: 18 } })
.stream()
.setBatchSize(1000)
.execute();
userStream.on('data', (user) => {
// Process each user
});
// Cached find operations
const users = await userDb.find(
{ age: { $gt: 18 } },
{
useCache: true, // Enable caching for this query
cacheTTL: 1800 // Custom TTL for this query
}
);
// Clear specific cache
await userDb.clearCache('cacheKey');
// Clear all cache
await userDb.clearAllCache();
// Get performance stats
const stats = userDb.getPerformanceStats();
console.log(stats);
// Output:
// {
// operations: {
// find: { count: 100, avgTime: 50, maxTime: 200 },
// create: { count: 50, avgTime: 30, maxTime: 100 }
// }
// }
// Watch for changes
const changeStream = userDb.watch();
changeStream.on('change', (change) => {
console.log('Document changed:', change);
});
const result = await userDb.aggregate([
{ $match: { age: { $gt: 18 } } },
{ $group: { _id: '$city', count: { $sum: 1 } } }
]);
const count = await userDb.estimatedCount();
const options = {
// Caching
enableCache: true,
cacheTTL: 3600, // seconds
// Rate Limiting
enableRateLimit: true,
rateLimit: {
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100 // requests per windowMs
},
// Performance Monitoring
enablePerformanceMonitoring: true
};
const userDb = new EasyMongo(UserModel, options);
// Text Search
const results = await userDb.search({
text: 'john', // search text
fields: ['name', 'email'], // fields to search
filter: { age: { $gt: 18 } }, // additional filters
sort: { score: { $meta: 'textScore' } },
limit: 10,
skip: 0
});
// Geo Search
const nearbyUsers = await userDb.searchNearby({
field: 'location',
coordinates: [longitude, latitude],
maxDistance: 1000, // meters
minDistance: 0,
limit: 10
});
// Fuzzy Search
const fuzzyResults = await userDb.fuzzySearch({
fields: ['name', 'email'],
searchTerm: 'jon', // will match 'john'
limit: 10
});
// Run operations in a transaction
await userDb.withTransaction(async (session) => {
await userDb.create({ name: 'Alice' });
await userDb.update({ name: 'Bob' }, { age: 25 });
// If any operation fails, all changes will be rolled back
});
// Bulk Write
await userDb.bulkWrite([
{ insertOne: { document: { name: 'John' } } },
{ updateOne: { filter: { name: 'Alice' }, update: { age: 26 } } }
]);
// Deep populate
const user = await userDb.findById('user_id');
const populatedUser = await userDb.populate(user, ['posts', 'comments']);
// Populate virtuals
const userWithVirtuals = await userDb.populateVirtuals(user, ['fullName']);
// Count documents
const count = await userDb.count({ age: { $gt: 18 } });
// Get distinct values
const uniqueAges = await userDb.distinct('age', { country: 'USA' });
// Check if exists
const exists = await userDb.exists({ email: 'john@example.com' });
await EasyMongo.disconnect();
MIT
For detailed documentation, please visit our Wiki.
const { findDocuments, updateDocument, deleteDocument } = require('easy-mongo');
// Find documents
const users = await findDocuments('users', { age: { $gt: 18 } });
// Update a document
await updateDocument('users', { _id: userId }, { $set: { status: 'active' } });
// Delete a document
await deleteDocument('users', { _id: userId });
We welcome contributions! Please see our Contributing Guide for details.
See CHANGELOG.md for a list of changes and updates.
FAQs
A powerful and elegant MongoDB/Mongoose toolkit that makes database operations a breeze with built-in performance monitoring, model management, and pagination
We found that mongoose-maestro demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.