> For the complete documentation index, see [llms.txt](https://docs.iynxdev.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.iynxdev.com/addon-api/getting-started/internal-api/user-data.md).

# User Data

This page explains how to work with Athena’s user data system.

## User data

User data is commonly stored in the database and can be accessed from your plugin. For example, if you want to fetch a user’s data object, you can use the built-in model accessors and work with the returned document.

```js
const model = this.heart.core.database.getModel('user').getModel();
const userData = await model.findOne({ userId: interaction.user.id });
```

You can then update it or create a new record if it does not exist.

```js
if (!userData) {
  await model.create({ userId: interaction.user.id, balance: 0 });
}
```

> Always make sure your data structure matches the schema used by the relevant model.
