
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
$ npm install ejoy-oplog
You need to configure your MongoDB instance (local instance) to have access to the oplog, here are some quick steps on how to do so:
Shutdown your existing mongo instance if its running.
Restart the instance. Use the --replSet
option to specify the name of the replica set.
$ sudo mongod --replSet rs0
mongo
in your terminal:$ mongo
rs.initiate()
to initiate the new replica set:> rs.initiate()
Once it is initiated then you are ready to start using ejoy-oplog
.
And here is the official MongoDB documentation if you need additional help on MongoDB replica set.
import MongoOplog from 'ejoy-oplog'
const oplog = MongoOplog('mongodb://127.0.0.1:27017/local', { ns: 'test.posts' })
oplog.tail();
oplog.on('op', data => {
console.log(data);
});
oplog.on('insert', doc => {
console.log(doc);
});
oplog.on('update', doc => {
console.log(doc);
});
oplog.on('delete', doc => {
console.log(doc.o._id);
});
oplog.on('error', error => {
console.log(error);
});
oplog.on('end', () => {
console.log('Stream ended');
});
oplog.stop(() => {
console.log('server stopped');
});
uri
: Valid MongoDB uri or a MongoDB server instance.options
MongoDB connection options.Start tailing.
This method support both Promise
and callback
.
oplog.tail().then(() => {
console.log('tailing started')
}).catch(err => console.error(err))
// or with async/await
async function tail() {
try {
await oplog.tail()
console.log('tailing started')
} catch (err) {
console.log(err)
}
}
Stop tailing and disconnect from server.
This method support both Promise
and callback
.
oplog.stop().then(() => {
console.log('tailing stopped')
}).catch(err => console.error(err))
// or with async/await
async function stop() {
try {
await oplog.stop()
console.log('tailing stopped')
} catch (err) {
console.log(err)
}
}
Destroy the mongo-oplog
object by stop tailing and disconnecting from server.
This method support both Promise
and callback
.
oplog.destroy.then(() => {
console.log('destroyed')
}).catch(err => console.error(err))
// or with async/await
async function destroy() {
try {
await oplog.destroy()
console.log('destroyed')
} catch (err) {
console.log(err)
}
}
Pause and resume oplog events.
oplog.ignore = true; // to pause
oplog.ignore = false // to resume
Create and return a filter object.
const filter = oplog.filter('*.posts')
filter.on('op', fn)
oplog.tail()
Destroy filter object.
filter.destroy()
Pause and resume filter events.
filter.ignore = true; // to pause
filter.ignore = false // to resume
Events supported by oplog
and filter
;
op
: All bellow operations (oplog/filter).insert
: Document insert (oplog/filter).update
: Document update (oplog/filter).delete
: Document delete (oplog/filter).end
: Cursor stream ended (oplog).error
: Error (oplog).Configure MongoDB for active oplog, once this is done then you can run the test:
$ npm install
$ npm run test
FAQs
Watch mongodb oplog in a simple way
We found that ejoy-oplog 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.