aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sokolov <eug-vs@keemail.me>2020-12-04 00:51:16 +0300
committerGitHub <noreply@github.com>2020-12-04 00:51:16 +0300
commitd513b23be26bda40d40ec43258345af6e34cfdfd (patch)
tree87b705d7ac983ba967d51205deace27b63e7d093
parent37b2f65939f173e80fdc835391bb2f8931476c55 (diff)
downloadmongo-cronjob-d513b23be26bda40d40ec43258345af6e34cfdfd.tar.gz
docs: add example client usage
-rw-r--r--README.md11
1 files changed, 9 insertions, 2 deletions
diff --git a/README.md b/README.md
index f7a6490..92f42f9 100644
--- a/README.md
+++ b/README.md
@@ -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);