> For the complete documentation index, see [llms.txt](https://docs.kubemq.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kubemq.io/configuration/connectors/kubemq-targets/gcp/firestore.md).

# Firestore

Kubemq gcp-firestore target connector allows services using kubemq server to access google firestore server.

## Prerequisites

The following required to run the gcp-firestore target connector:

* kubemq cluster
* gcp-firestore set up in native mode
* kubemq-source deployment

## Configuration

firestore target connector configuration properties:

| Properties Key | Required | Description               | Example                     |
| -------------- | -------- | ------------------------- | --------------------------- |
| project\_id    | yes      | gcp firestore project\_id | "/myproject"                |
| credentials    | yes      | gcp credentials files     | "\<google json credentials" |

Example:

```yaml
bindings:
  - name: kubemq-query-gcp-firestore
    source:
      kind: kubemq.query
      name: kubemq-query
      properties:
        address: "kubemq-cluster:50000"
        client_id: "kubemq-query-gcp-firestore-connector"
        auth_token: ""
        channel: "query.gcp.firestore"
        group:   ""
        auto_reconnect: "true"
        reconnect_interval_seconds: "1"
        max_reconnects: "0"
    target:
      kind: gcp.firestore
      name: gcp-firestore
      properties:
        project_id: "id"
        credentials: 'json'
        instance:  "instance"
```

## Usage

### Add Key

add a key under collection

Add Key metadata setting:

| Metadata Key | Required | Description                           | Possible values   |
| ------------ | -------- | ------------------------------------- | ----------------- |
| method       | yes      | type of method                        | "add"             |
| collection   | yes      | the name of the collection to sent to | "collection name" |

Example:

```javascript
{
  "metadata": {
    "method": "add",
    "collection": "my_collection"
  },
  "data": "QWRkIFZhbHVl"
}
```

### get Values by document key

get values by key under collection

Get Key metadata setting:

| Metadata Key  | Required | Description                           | Possible values      |
| ------------- | -------- | ------------------------------------- | -------------------- |
| method        | yes      | type of method                        | "document\_key"      |
| collection    | yes      | the name of the collection to sent to | "collection name"    |
| document\_key | yes      | the name of the key to get his value  | "valid existing key" |

Example:

```javascript
{
  "metadata": {
    "method": "documents_all",
    "collection": "my_collection",
    "item": "<valid existing key>"
  },
  "data": null
}
```

### get all Values

get all values under collection

Get all metadata setting:

| Metadata Key | Required | Description                           | Possible values   |
| ------------ | -------- | ------------------------------------- | ----------------- |
| method       | yes      | type of method                        | "documents\_all"  |
| collection   | yes      | the name of the collection to sent to | "collection name" |

Example:

```javascript
{
  "metadata": {
    "method": "documents_all",
    "collection": "my_collection"
  },
  "data": null
}
```

### delete key

delete key in collection

Delete key metadata setting:

| Metadata Key  | Required | Description                             | Possible values         |
| ------------- | -------- | --------------------------------------- | ----------------------- |
| method        | yes      | type of method                          | "delete\_document\_key" |
| collection    | yes      | the name of the collection to sent to   | "collection name"       |
| document\_key | yes      | the name of the key to delete his value | "valid existing key"    |

Example:

```javascript
{
  "metadata": {
    "method": "delete_document_key",
    "collection": "my_collection",
    "item": "valid existing key"
  },
  "data": null
}
```
