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

***

# Function: writeDataStoreToService()

> **writeDataStoreToService**(`directory`): (`container`, `service`, `options`) => `Promise`<`void`>

Defined in: data-stores.ts:168

Write an data store (e.g. database, cache, etc.) to a service in EventCatalog.

You can optionally override the path 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                                                                      |
| ------------------- | ------------------------------------------------------------------------- |
| `container`         | `Container`                                                               |
| `service`           | { `id`: `string`; `version`: `string`; }                                  |
| `service.id`        | `string`                                                                  |
| `service.version`?  | `string`                                                                  |
| `options`           | { `format`: `"md"` \| `"mdx"`; `override`: `boolean`; `path`: `string`; } |
| `options.format`?   | `"md"` \| `"mdx"`                                                         |
| `options.override`? | `boolean`                                                                 |
| `options.path`?     | `string`                                                                  |

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

`Promise`<`void`>

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

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

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

// Write a data store to a given service in the catalog
// Data store would be written to services/Inventory/containers/orders-db
await writeDataStoreToService({
  id: 'orders-db',
  name: 'Orders DB',
  version: '0.0.1',
  summary: 'This is a summary',
  markdown: '# Hello world',
  container_type: 'database',
}, { id: 'Inventory' });
```

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

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

// Write a container to a given service in the catalog
// Container would be written to services/Inventory/containers/orders-db
await writeContainerToService({
  id: 'orders-db',
  name: 'Orders DB',
  version: '0.0.1',
  summary: 'This is a summary',
  markdown: '# Hello world',
  container_type: 'database',
}, { id: 'Inventory' });
```
