# Edit

## Save Content <a href="#content" id="content"></a>

{% code lineNumbers="true" %}

```javascript
const record = db.get('tag')
record.content.KEY = "VALUE"
// or record.content = "VALUE"
record.save()
```

{% endcode %}

## Append to Record <a href="#append" id="append"></a>

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

```javascript
db.get('tag').append(content)
```

{% endcode %}
{% endtab %}

{% tab title="Prepend" %}

```javascript
db.get('tag').prepend(content)
```

{% endtab %}
{% endtabs %}

<table><thead><tr><th>Parameter</th><th>About</th><th>Type</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>content</td><td>The content to add</td><td>Any</td><td>true</td></tr></tbody></table>

## Truncate Record <a href="#length" id="length"></a>

{% code lineNumbers="true" %}

```javascript
db.get('tag').truncate(length)
```

{% endcode %}

<table><thead><tr><th>Parameter</th><th>About</th><th>Type</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>length</td><td>New file length</td><td>Number</td><td>true</td></tr></tbody></table>

## Edit Record Content <a href="#overwrite" id="overwrite"></a>

{% hint style="danger" %}
This will overwrite your record with the content provided.
{% endhint %}

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

```javascript
db.get('tag').edit(content)
```

{% endcode %}
{% endtab %}

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

```javascript
db.edit("tag", content)
```

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

<table><thead><tr><th>Parameter</th><th>About</th><th>Type</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>tag</td><td>The Record's tag</td><td>String</td><td>true</td></tr><tr><td>content</td><td>The content to overwrite with</td><td>Any (must match file extension)</td><td>true</td></tr></tbody></table>

## Modify a Key

{% hint style="danger" %}

### JSON Only

This function only modifies objects.
{% endhint %}

```javascript
db.get('tag').modify(key, value)
```

<table><thead><tr><th>Parameter</th><th>About</th><th>Typr</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>key</td><td>The key to set the value to</td><td>String</td><td>true</td></tr><tr><td>value</td><td>The value to set the key to</td><td>Any</td><td>true</td></tr></tbody></table>

## Modify a Record's Tag <a href="#tag" id="tag"></a>

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

```javascript
db.get('old_tag').setTag('new_tag')
```

{% endcode %}
{% endtab %}

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

```javascript
db.setTag('old_tag', 'new_tag')
```

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

<table><thead><tr><th>Parameter</th><th>About</th><th>Type</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>old_tag</td><td>The current tag of the Record.</td><td>String</td><td>true</td></tr><tr><td>new_tag</td><td>The new tag you want for the Record.</td><td>String</td><td>true</td></tr></tbody></table>

## Overwrite from another Record <a href="#syncwith" id="syncwith"></a>

{% code lineNumbers="true" %}

```javascript
db.get('tag').syncWith('_tag')
```

{% endcode %}

<table><thead><tr><th>Parameter</th><th>About</th><th>Type</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>_tag</td><td>The tag of the Record you want to get the content from.</td><td>String</td><td>true</td></tr></tbody></table>

## Beautify JSON

{% hint style="danger" %}

### JSON Only

This function only modifies objects.
{% endhint %}

{% code lineNumbers="true" %}

```javascript
db.get('tag').beautify(replacer, space)
```

{% endcode %}

<table><thead><tr><th>Parameter</th><th>About</th><th>Type</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>replacer</td><td>A function that transforms the results.</td><td>Function</td><td>false</td></tr><tr><td>space</td><td>Adds indentation, white space, and line break characters to the return-value to make it easier to read. Default: 2</td><td>Number</td><td>false</td></tr></tbody></table>

## Empty Record

Emptying a Record deletes the Record content but preserves the file.

{% code lineNumbers="true" %}

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

{% endcode %}

### Check if a Record is empty

{% code lineNumbers="true" %}

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

{% endcode %}
