# Modifying Data

## Declaring Variable

```javascript
const FlameDB = require("flame.db");
const db = new FlameDB();
```

## Methods

* `db.create(path, value)`
* `db.set(path, value)`
* `db.update(path, value)`
* `db.push(path, value)`

### create(path, value)

This will create a new collection and documents.

```javascript
// Create a new collection -- {balance: 1000, coins: 12000}
db.create("users/566851016910438400", {balance: 1000, coins: 12000})
```

### set(path, value)

Modify the whole document data. This is different than the `update` method

```javascript
// Modify the whole document data -- {balance: 1000, money: 12000}
db.set("users/566851016910438400", {balance: 1000, money: 12000})
```

### update(path, value)

Modify only the specified field in the document data

```javascript
// Modify only the specified field -- {balance: 2000, money: 12000}
db.update("users/566851016910438400", {balance: 2000})
```

### push(path, value)

Push item into an array inside the document

```javascript
// Push item into an array -- {balance: 2000, money: 12000, items: ["Laptop"]}
db.push("users/566851016910438400/items", "Laptop")
```


---

# 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://cjho88793.gitbook.io/flamedb/modifying-data.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.
