> For the complete documentation index, see [llms.txt](https://db.coolstone.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://db.coolstone.dev/4/core/delete.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
