Mongo Log
Mongo log is an append only log management system built on top of mongodb. It can be used to provide either a node module or a rest api.
Setup
Rest Api
First install the module globally
npm install --global mongo-log
Then start the server
mongo-server
This will start the server locally, defaulting to port 5000.
Node Api
First install the module
npm install mongo-log
Then require it
const MongoLog =
Scheme
The schema for an event item is
Rest Api
GET /api/log
Returns a list of every event
URL Params
after
- A JavaScript time stamp used to filter events chronologicallybefore
- A JavaScript time stamp used to filter events chronologically
Schema
POST /api/log
Adds a new event
Schema
DELETE /api/log
Clears all log events
Schema
Node Module
The node node module exports a single class that is constructed with a mongodb connection.
cosnt mongoLog = db
Regular Methods
all methods return promises
addEntry(data)
- adds a new log entrygetEntries()
- gets all log entriesclear()
- removes all log entriessize()
- gets the number of log entries
Filtering Methods
filtering methods return a new instance of MongoLog
, which regular methods or other filtering methods can then be called on.
after(timeStamp)
- restricts events to after a specefic datebefore(timeStamp)
- restricts events to before a specefic datequery(query)
- restrict based on a mongodb query to the events data