Skip to content

Commit

Permalink
GITBOOK-29: No subject
Browse files Browse the repository at this point in the history
  • Loading branch information
code-xhyun authored and gitbook-bot committed May 8, 2024
1 parent 7e486c1 commit ff31b6f
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 7 deletions.
2 changes: 2 additions & 0 deletions gitbook/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@
* [Save](docs/managing-jobs/manually-working/save.md)
* [Unique](docs/managing-jobs/manually-working/unique.md)
* [RepeatEvery](docs/managing-jobs/manually-working/repeatevery.md)
* [Schedule](docs/managing-jobs/manually-working/repeatevery-1.md)
* [Remove](docs/managing-jobs/manually-working/repeatevery-2.md)
40 changes: 40 additions & 0 deletions gitbook/docs/managing-jobs/manually-working/repeatevery-1.md
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 gitbook/docs/managing-jobs/manually-working/repeatevery-2.md
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`.

\


\




9 changes: 2 additions & 7 deletions gitbook/docs/managing-jobs/manually-working/save.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();


```
Expand Down

0 comments on commit ff31b6f

Please sign in to comment.