
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
mongoose-divide-and-conquer
Advanced tools
Allows you to divide and conquer an entire mongo collection using mongoose.
We can give divide a model, and it will find id ranges for the given batch size. These can be pushed onto a queue for processing.
var waitress = require('waitress')
, PikaQueue = require('pika-queue')
, daq = require('mongoose-divide-and-conquer')
, Model = require('./some/model')
, queue = new PikaQueue()
;
daq.divide({
model: Model,
batchSize: 1000
}, function(err, batches) {
if (err) throw err;
var done = waitress(batches.length, function(err) {
if (err) throw err;
console.log('all done!');
process.exit();
});
console.log('queueing %d batches', batches.length);
batches.forEach(function(batch, i) {
queue.queueJob('divide-and-conquer', batch, function(err) {
console.log('batch %s finished', i);
done(err);
});
});
});
We can pop batches off the queue, and give them to conquer with two methods.
The first method is used to process one document. The second method is called when all documents have been processed. All documents from the batch are processed in parallel.
var waitress = require('waitress')
, PikaQueue = require('pika-queue')
, daq = require('mongoose-divide-and-conquer')
, Model = require('./some/model')
, queue = new PikaQueue()
;
queue.monitorJobQueue('divide-and-conquer', function(batch, cb) {
daq.conquer(
{
batch: batch,
model: Model
},
function(doc, done) {
// do something with the document
process.stdout.write('.');
done();
},
function(err, count) {
if (err) throw err;
console.log();
console.log('processed %d docs', count);
cb(null, count);
}
);
});
FAQs
divide and conquer mongoose collections
We found that mongoose-divide-and-conquer 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.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.