> For the complete documentation index, see [llms.txt](https://textav.gitbook.io/firebase-react-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://textav.gitbook.io/firebase-react-notes/firestore/firestore-write.md).

# Firestore write

<https://firebase.google.com/docs/firestore/manage-data/add-data#set_a_document>

```javascript
db.collection("transcripts").add({
  title: "new one",
  description: "new description"
})
.then(function(docRef) {
  console.log("Document written with ID: ", docRef.id);
})
.catch(function(error) {
  console.error("Error adding document: ", error);
});
```

####

## Indexing

There current is roughly 40,000 limit to indexing for Firestore.

<https://firebase.google.com/docs/firestore/query-data/index-overview#indexing_best_practices>

> Large string fields\
> If you have a string field that often holds long string values that you don’t use for querying, you can cut storage costs by exempting the field from indexing.

{% embed url="<https://firebase.google.com/docs/firestore/query-data/indexing>" %}

### Remove indexes <a href="#remove_indexes" id="remove_indexes"></a>

To delete an index:

1. Go to the **Database** section of the [Firebase console](https://console.firebase.google.com/project/_/database/firestore/data).
2. Click the **Indexes** tab.
3. Hover over the index you want to delete and select **Delete** from the context menu.
4. Confirm that you want to delete it by clicking **Delete** from the alert.

It doesn't mention anywhere how to do this programmatically... :(&#x20;

## Server Timestamp

{% embed url="<https://firebase.google.com/docs/reference/node/firebase.firestore.FieldValue.html#servertimestamp>" %}

You need access to FieldValue, which is available from `firebase.firestore.FieldValue.serverTimestamp()`

This can also be used client side&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://textav.gitbook.io/firebase-react-notes/firestore/firestore-write.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.
