# Adapter Interface

## Description

Adapters allow us to persist **events** (for the write model) and/or **projections** (for the read model).

If you can't find an adapter for your favorite database, you can build one by implementing the **Adapter Interface**.

The **Adapter Interface** has two sets of methods, depending if you are persisting **events**, **projections**, or both. Not every database is suitable for storing both. DynamoDB, for example, is very well suited for storing **events**, but lacks the search capabilities which are useful when storing **projections**. ElasticSearch, on the other hand, is great for storing, and searching, arbitrary JSON objects (**projections**) but is not very well suited for a stack of **events**.

When implementing the **Adapter Interface**, you can choose which set of methods to implement.

## Methods

{% content-ref url="/pages/-LUyNOwwcsqfGHXnzCAn" %}
[Write Model](/advanced/repository/write-model.md)
{% endcontent-ref %}

{% content-ref url="/pages/-LUyNJl2367gscStKtKh" %}
[Read Model](/advanced/repository/read-model.md)
{% endcontent-ref %}

## Examples

{% content-ref url="/pages/-LUjLs3AamWPsuHWvAO1" %}
[dynamodb-adapter](/components/dynamodb-adapter.md)
{% endcontent-ref %}

{% content-ref url="/pages/-LUjLupsvTm0wgn61G7Q" %}
[elasticsearch-adapter](/components/elasticsearch-adapter.md)
{% endcontent-ref %}

{% content-ref url="/pages/-LUpbXDIxYVs7BTwZb5p" %}
[memory-adapter](/components/memory-adapter.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.serverless-cqrs.com/advanced/repository.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
