low-json-db

Events

Both the database and collections inherit from EventEmitter. You can listen to useful lifecycle events.

Listening to Events

const db = new JSONDB('./data');

db.on('save', (info) => {
  console.log('Saved collection:', info.collection);
});

db.on('error', (err) => {
  console.log('Error:', err.message);
});

db.on('insert', (info) => {
  console.log('Inserted into', info.collection);
});

db.on('backup', (info) => {
  console.log('Backup created at', info.path);
});

Available Events

Next: See all Collection Options.