> For the complete documentation index, see [llms.txt](https://cjho88793.gitbook.io/flamedb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cjho88793.gitbook.io/flamedb/modifying-data.md).

# 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")
```
