# Delete

{% tabs %}
{% tab title="1" %}
{% code lineNumbers="true" %}

```javascript
db.get('tag').delete()
```

{% endcode %}
{% endtab %}

{% tab title="2" %}
{% code lineNumbers="true" %}

```javascript
db.delete('tag')
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Trash

If you set `trash`, Records will **not** be deleted, but rather moved to your trash.

#### Delete All from Trash

{% code lineNumbers="true" %}

```javascript
db.emptyTrash()
```

{% endcode %}

#### Delete from Trash

{% code lineNumbers="true" %}

```javascript
db.deleteFromTrash('tag')
```

{% endcode %}

| Parameter | About                     | Type   |
| --------- | ------------------------- | ------ |
| tag       | Tag of the trashed record | String |

#### Restore From Trash

<pre class="language-javascript" data-line-numbers><code class="lang-javascript"><strong>db.restoreFromTrash('tag')
</strong></code></pre>

| Parameter | About                     | Type   |
| --------- | ------------------------- | ------ |
| tag       | Tag of the trashed record | String |

## Close

Delete **all** records & the directory

{% code lineNumbers="true" %}

```javascript
db.close()
```

{% endcode %}

## Wipe

Delete **all** records & *preserve* the directory

{% code lineNumbers="true" %}

```javascript
db.wipe()
```

{% endcode %}

## Delete Old Records

{% code lineNumbers="true" %}

```javascript
db.deleteOld({ ms:5, seconds:5, minutes:5, hours:5, days:0})
```

{% endcode %}

Requires at least one of the options below (multiple options will stack)

<table><thead><tr><th>Parameter</th><th>About</th><th>Type</th><th data-hidden data-type="checkbox">Required</th></tr></thead><tbody><tr><td>ms</td><td>Milliseconds</td><td>Number</td><td>false</td></tr><tr><td>seconds</td><td>Seconds</td><td>Number</td><td>false</td></tr><tr><td>minutes</td><td>Minutes</td><td>Number</td><td>false</td></tr><tr><td>hour</td><td>Hours</td><td>Number</td><td>false</td></tr><tr><td>days</td><td>Days</td><td>Number</td><td>false</td></tr></tbody></table>

## Delete Large Records

{% code lineNumbers="true" %}

```javascript
db.deleteLarge(size)
```

{% endcode %}

<table><thead><tr><th>Parameter</th><th>About</th><th>Type</th><th data-hidden data-type="checkbox">Required</th></tr></thead><tbody><tr><td>size</td><td>Size of the file in bytes</td><td>Number</td><td>false</td></tr></tbody></table>

## Safe Unlink

{% hint style="info" %}
This function is already used internally, but you can also use it yourself
{% endhint %}

{% code lineNumbers="true" %}

```javascript
db.safeUnlink(tag)
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://db.coolstone.dev/4/core/delete.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
