diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-12-04 00:51:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-04 00:51:16 +0300 |
commit | d513b23be26bda40d40ec43258345af6e34cfdfd (patch) | |
tree | 87b705d7ac983ba967d51205deace27b63e7d093 | |
parent | 37b2f65939f173e80fdc835391bb2f8931476c55 (diff) | |
download | mongo-cronjob-d513b23be26bda40d40ec43258345af6e34cfdfd.tar.gz |
docs: add example client usage
-rw-r--r-- | README.md | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -3,9 +3,16 @@ Cron-based job scheduler which persists events to MongoDB ## Usage example ```js -// Define schema for event context and wrap it into a model +const mongoose = require('mongoose'); +const { Client, Scheduler } = require('mongo-cronjob'); + +// Define schema for event context const contextSchema = new Schema({ message: String }); -const EventModel = model('Event', contextSchema); + +// Initialize client with existing connection +const client = new Client(mongoose.connection, contextSchema); +const EventModel = client.Event; +const LogModel = client.Log; // Initialize scheduler const scheduler = new Scheduler(EventModel); |