# SetSimpleData()

## Description

This function creates or overwrites a document in the database. If the collection does not exist, the collection will be created. If the document does not exist, it will be created.

#### Syntax

```
SetSimpleData(collectionName, documentName, mapStruct)
```

| Argument         | Description                                                                                                                 |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `collectionName` | <p>The name of the collection in the root of your database where you want to edit a document.<br>This must be a String.</p> |
| `documentName`   | <p>The name of the document you are creating/updating.<br>This must be a String.</p>                                        |
| `mapStruct`      | <p>The data you want to store at this location.<br>This must be a Struct of key-value pairs of your data.</p>               |

#### Returns

```
Number  // a positive integer you can note down
```

## Example Implementation

<pre><code><strong>var playerInfo = {
</strong><strong>    ip: "155.34.22.11",
</strong><strong>    location : "Ontario"
</strong><strong>}
</strong><strong>var name = get_string("Whats your name?","Name");  ///user replies lilshake
</strong><strong>var writeId = SetSimpleData("users", "name", playerInfo)
</strong></code></pre>

This requests the server to create this struct as a document with name "lilshake"

the **callback\_SetSimpleData()** actually gives the confirmation of the write.


---

# 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://rocket-networking.gitbook.io/docs/rocket-networking-code/database-functions/setsimpledata.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.
