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

# saveData

Save data in the database

To save data you need the server object from getLocalServer, a schema and the data you want to save.

Firstly create the schema:

1. Create new folder named 'Schemas'. You can use any name you want.
2. Create new file named 'example.js' in the new folder. You can use any name you want.
3. Paste the schema code inside (below this list)

{% code title="example.js" lineNumbers="true" %}

```javascript
const schema = {
    name: String,
    lastname: String,
    age: Number,
};

const props = {
    name: 'example', // Schema Name
    schema: schema // Schema Object
};

module.exports = props;
```

{% endcode %}

Now you created your own schema. You can now import the schema and save the data.

{% code lineNumbers="true" %}

```javascript
const { LocalServer, getLocalServer, saveData } = require('naturesaving');
const ExampleSchema = require('path-to-schema') // The path to your schema

const server = new LocalServer({ name: 'Example', path: './database' });

const localServer = getLocalServer({ name: 'Example' });

const data = {
    name: 'Max',
    lastname: 'Mustermann',
    age: 50
};

saveData({ server: localServer, schema: ExampleSchema, data: data }); // Save the data
```

{% endcode %}
