Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 1.5 KB

README_STORAGE_HISTORY.md

File metadata and controls

54 lines (37 loc) · 1.5 KB

ConstructorOptions

Options for class constructor

Properties

  • client MongoClient configured mongo client to use. Can be null if url is set
  • databaseName string? name of the mongodb database
  • collectionName string name of the mongodb collection used to store the resources
  • usageEventPrefix string the usageEventPrefix of the target storage module

Examples

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()

ResourceStorageHistory

Simple resource class that will listen to storage event of the given eventEmitter to populate a history collection / table.

listenForStorageEvents

Activate listening for storage events to monitor changes of target storage resource to populate the history table.

close

Closes the database client

Returns void