# 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
}
```


---

# 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://docs.kubemq.io/configuration/connectors/kubemq-targets/gcp/firestore.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.
