Options for class constructor
client
MongoClient configured mongo client to use. Can be null if url is setdatabaseName
string? name of the mongodb databasecollectionName
string name of the mongodb collection used to store the resourcesusageEventPrefix
string the usageEventPrefix of the target storage module
const { EventEmiter } from 'events'
const { OneToFewResourceStorage, ResourceStorageHistory } = require('@discue/mongodb-resource-client')
const eventEmitter = new EventEmitter()
const collectionName = 'api_clients'
const url = 'mongodb://127.0.0.1:27017'
const oneToFewResourceStorage = new OneToFewResourceStorage({
url,
collectionName,
eventEmitter
})
const history = new ResourceStorageHistory({
url,
collectionName,
usageEventPrefix: oneToFewResourceStorage.usageEventPrefix
eventEmitter
})
history.listenForStorageEvents()
Simple resource class that will listen to storage event of the given eventEmitter to populate a history collection / table.
Activate listening for storage events to monitor changes of target storage resource to populate the history table.
Closes the database client
Returns void