# Update an existing document

To update an existing document, you'll need a reference to it. You can directly reference a document by its ID, or you can access the `ref` property on a snapshot of the document.

{% tabs %}
{% tab title="Direct Reference" %}

```javascript
const ref = adamite()
  .database()
  .collection("projects")
  .doc("documentId")
```

{% endtab %}

{% tab title="Indirect Reference" %}

```javascript
const projects = 
  await adamite()
    .database()
    .collection("projects")
    .get();
    
const ref = projects.docs[0].ref;
```

{% endtab %}
{% endtabs %}

Once you have a reference to the document, you can update its data using the `update` function.

```javascript
await ref.update({
  name: "Some other name"
});
```
