mongo-job-scheduler 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +19 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -79,15 +79,33 @@ await scheduler.schedule({
79
79
  ### Interval Jobs
80
80
 
81
81
  ```typescript
82
+ // Using milliseconds directly
82
83
  await scheduler.schedule({
83
84
  name: "cleanup-logs",
84
85
  data: {},
85
86
  repeat: {
86
- every: 5 * 60 * 1000, // every 5 minutes (in milliseconds)
87
+ every: 5 * 60 * 1000, // every 5 minutes
87
88
  },
88
89
  });
90
+
91
+ // Helper pattern for human-readable intervals
92
+ const minutes = (n: number) => n * 60 * 1000;
93
+ const hours = (n: number) => n * 60 * 60 * 1000;
94
+ const days = (n: number) => n * 24 * 60 * 60 * 1000;
95
+
96
+ await scheduler.schedule({
97
+ name: "daily-backup",
98
+ repeat: { every: days(1) }, // 1 day
99
+ });
100
+
101
+ await scheduler.schedule({
102
+ name: "hourly-sync",
103
+ repeat: { every: hours(2) }, // 2 hours
104
+ });
89
105
  ```
90
106
 
107
+ > **📌 Repeat Job Status**: Repeating jobs cycle through `pending` → `running` → `pending` (rescheduled). The same job document is reused with an updated `nextRunAt`. Jobs stay in the database until cancelled.
108
+
91
109
  ### Bulk Scheduling
92
110
 
93
111
  For high-performance ingestion:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongo-job-scheduler",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Production-grade MongoDB-backed job scheduler with retries, cron, timezone support, and crash recovery",
5
5
  "license": "MIT",
6
6
  "author": "Darshan Bhut",