> For the complete documentation index, see [llms.txt](https://simpldb.js.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simpldb.js.org/v2.11.0/documentation/database/set.md).

# .set()

Sets a new value to the value of the provided key.

### set(key, value, encrypt)

<table data-header-hidden><thead><tr><th width="532">Parameter</th><th align="center">Default</th><th>Description</th></tr></thead><tbody><tr><td><strong>Parameter</strong></td><td align="center"><strong>Default</strong></td><td><strong>Description</strong></td></tr><tr><td>key</td><td align="center"> </td><td><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></p><p>The target key</p></td></tr><tr><td>value</td><td align="center"> </td><td><p><a href="https://simpldb.gitbook.io/docs/types-and-interfaces/jsondata">JSONData</a></p><p>The value to set</p></td></tr><tr><td>encrypt</td><td align="center"><code>false</code></td><td><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a> (optional)</p><p>Whether or not to encrypt the value before setting it</p></td></tr></tbody></table>

| **Returns**                                                                                                                                    | **Description**                               |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
| [JSONData](https://simpldb.gitbook.io/docs/types-and-interfaces/jsondata) \| [Data](https://simpldb.gitbook.io/docs/types-and-interfaces/data) | The updated data from the provided key's root |

####

```javascript
db.set('user', { name: 'Peter' }); // { name: 'Peter' }

db.get('user'); // { name: 'Peter' }
```

Also allows the use of dot notation:

```javascript
db.get('user'); // { name: 'Peter' }

db.set('user.age', 19); // { name: 'Peter', age: 19 }
```

And the possibility to encrypt the data to safely store it:

```javascript
db.set('PASSWORD', 'password123', true); // d95e3df34d0a39c3177adf393e90c533:d861d25474fb4fe0c921be 
```

And even a way to delete an entry from the database (**version 2.0.2 and above**):

```javascript
db.get('user'); // { name: 'Peter', age: 19 }

db.set('user.age', undefined); // { name: 'Peter' } 
```
