function EventedDatastore (options) { var self = this // Add EventEmitter capabilities self.__events = new EventEmitter() options = options || {} var autoLoadOption = options.autoload || false options.autoload = false Datastore.call(self, options) options.autoload = autoLoadOption self.autoload = autoLoadOption // Temporary properties used to collect data for event emissions self.__removedDocs = null self.__modifications = null if (self.autoload) { // Wait till the next tick to allow time for event listeners to be attached process.nextTick(function () { self.loadDatabase(options.onload || function (err) { if (err) { throw err } }) }) } }