4.1.2 • Published 8 years ago
mongodb-tail v4.1.2
mongodb-tail
Module to tail MongoDB capped collection using MongoDB Native NodeJS Driver
require("mongodb-tail")
Example
const mongodb = require('mongodb');
const tail = require('mongodb-tail');
mongodb.connect('mongodb://localhost:27017/local?replicaSet=rs')
.then((db) => {
tail(
db.collection('oplog.rs'),
(latest) => ({
ts: { $gt: latest.ts },
fromMigrate: { $exists: false },
ns: 'test.test',
op: {
$in: ['i', 'u', 'd']
}
})
)
.on('error', console.error)
.on('next', console.log);
})
.catch((err) => {
console.error(err);
process.exit(1);
});
Tail factory
require("mongodb-tail")(collection, build, opts)
@param {Object} collection - MongoDB collection
@param {build} build - function to build MongoDB query
@param {Object} [opts] - MongoDB cursor options
@param {number} [opts.numberOfRetries = Number.MAX_VALUE]
@param {number} [opts.tailableRetryInterval = 1000]
@param {number} [opts.errorTimeout = 1000]
@returns {tail}
@typedef {function} build - function to build MongoDB query
@param {Object} latest - latest MongoDB document
@returns {Object} - MongoDB query
@typedef {Object} tail - instance of EventEmitter
@fires error - on error
@fires next - on stream data
Tests
- set MONGODB_TEST_CONNECTION_STRING and MONGODB_LOCAL_CONNECTION_STRING environment variables
- run
npm test
4.1.2
8 years ago
4.1.1
8 years ago
4.1.0
9 years ago
4.0.1
9 years ago
4.0.0
9 years ago
3.1.4
9 years ago
3.1.3
9 years ago
3.1.2
9 years ago
3.1.1
9 years ago
3.1.0
9 years ago
3.0.0
9 years ago
2.1.0
10 years ago
2.0.0
10 years ago
1.1.0
10 years ago
1.0.0
10 years ago
0.3.4
10 years ago
0.3.3
10 years ago
0.3.2
10 years ago
0.3.1
10 years ago
0.3.0
10 years ago
0.2.1
10 years ago
0.2.0
10 years ago
0.1.0
10 years ago