Copy as Markdown[View as Markdown](/docs/sdk/functions/addFileToDataStore.md)

***

# Function: addFileToDataStore()

> **addFileToDataStore**(`directory`): (`id`, `file`, `version`?) => `Promise`<`void`>

Defined in: data-stores.ts:143

Add a file to a data store (e.g. database, cache, etc.) by it's id.

Optionally specify a version to add a file to a specific version of the data store.

## Parameters[​](#parameters "Direct link to Parameters")

| Parameter   | Type     |
| ----------- | -------- |
| `directory` | `string` |

## Returns[​](#returns "Direct link to Returns")

`Function`

### Parameters[​](#parameters-1 "Direct link to Parameters")

| Parameter        | Type                                           |
| ---------------- | ---------------------------------------------- |
| `id`             | `string`                                       |
| `file`           | { `content`: `string`; `fileName`: `string`; } |
| `file.content`   | `string`                                       |
| `file.fileName`? | `string`                                       |
| `version`?       | `string`                                       |

### Returns[​](#returns-1 "Direct link to Returns")

`Promise`<`void`>

## Examples[​](#examples "Direct link to Examples")

```
import utils from '@eventcatalog/utils';

const { addFileToDataStore } = utils('/path/to/eventcatalog');

// adds a file to the latest InventoryAdjusted data store
await addFileToDataStore('InventoryAdjusted', { content: 'Hello world', fileName: 'hello.txt' });

// adds a file to a specific version of the InventoryAdjusted data store
await addFileToDataStore('InventoryAdjusted', { content: 'Hello world', fileName: 'hello.txt' }, '0.0.1');
```

```
import utils from '@eventcatalog/utils';

const { addFileToContainer } = utils('/path/to/eventcatalog');

// adds a file to the latest InventoryAdjusted event
await addFileToContainer('InventoryAdjusted', { content: 'Hello world', fileName: 'hello.txt' });

// adds a file to a specific version of the InventoryAdjusted event
await addFileToContainer('InventoryAdjusted', { content: 'Hello world', fileName: 'hello.txt' }, '0.0.1');
```
