-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e486c1
commit ff31b6f
Showing
4 changed files
with
81 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
gitbook/docs/managing-jobs/manually-working/repeatevery-1.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Schedule | ||
|
||
|
||
|
||
## `job.schedule(time)` | ||
|
||
{% hint style="info" %} | ||
The `schedule` method sets a job to run at a specific time determined by the input parameter. This method accepts both `Date` objects and date strings, providing flexibility in scheduling jobs.\ | ||
\ | ||
|
||
|
||
_This does **NOT** save the job in the database. you must explicitly declare_ [_`save()`_](save.md)_if you want to save it_ | ||
{% endhint %} | ||
|
||
### Example Usage | ||
|
||
{% code fullWidth="false" %} | ||
```typescript | ||
job.schedule(new Date(2023, 11, 17, 10, 30)); | ||
await job.save(); // If you want to save it | ||
|
||
``` | ||
{% endcode %} | ||
|
||
### Parameters | ||
|
||
* **`time`** (`string | Date`): The time at which the job is scheduled to run. This can be a `Date` object representing the exact time for the job to run. | ||
|
||
\ | ||
|
||
|
||
### Returns | ||
|
||
* **`Job`**: Returns the job instance with the updated `nextRunAt` attribute, allowing for method chaining. | ||
|
||
\ | ||
|
||
|
||
|
||
|
37 changes: 37 additions & 0 deletions
37
gitbook/docs/managing-jobs/manually-working/repeatevery-2.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Remove | ||
|
||
|
||
|
||
## `job.remove()` | ||
|
||
{% hint style="info" %} | ||
The `remove` method deletes a specific job from the MongoDB database, ensuring that it is no longer available for processing or querying. This method is crucial for managing job lifecycle and maintaining a clean job queue. | ||
|
||
|
||
{% endhint %} | ||
|
||
### Example Usage | ||
|
||
{% code fullWidth="false" %} | ||
```typescript | ||
job.remove(); | ||
``` | ||
{% endcode %} | ||
|
||
### Parameters | ||
|
||
\ | ||
|
||
|
||
### Returns | ||
|
||
* **`Promise<number | undefined>`**: A promise that resolves with the number of documents removed from the database. If no document is found with the specified job ID, it may resolve to `undefined`. | ||
|
||
\ | ||
|
||
|
||
\ | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,13 +14,8 @@ The `save` method commits the current state of a job to the MongoDB database. Th | |
```typescript | ||
const pulse = new Pulse(); | ||
|
||
pulse.define('test', async (job) => { | ||
if (job.isExpired()) { | ||
console.log('The job lock has expired.'); | ||
} else { | ||
console.log('The job lock is still valid.'); | ||
} | ||
}); | ||
const job = pulse.create('delete old users', { to: '[email protected]' }); | ||
job.save(); | ||
|
||
|
||
``` | ||
|