# Data Collections

The Hyperspace database stores data under Collections, which are distinct segments within the database. Before using the following commands, you must establish a local Hyperspace instance in order to allocate the essential resources and functions.

* Creating a Collection
* Committing a Collection
* Deleting a Collection
* Clearing a Collection
* Getting a Collection Scheme

**Creating a Collection**

The following command creates a Collection.

{% tabs %}
{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
hyperspace_client.create_collection('schema.json', collection_name')
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
hyperspaceClient.createCollection('schema.json', collection_name');
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}

<pre class="language-javascript" data-line-numbers><code class="lang-javascript"><strong>await hyperspaceClient.createCollection('schema.json', collection_name');
</strong></code></pre>

{% endtab %}
{% endtabs %}

**Where** –

* <mark style="color:purple;">schema.json</mark> – Specifies the path to the configuration file (for example, \\**schema.json**) that you created locally on your machine, as described in Creating a Database Schema Configuration File.
* <mark style="color:purple;">collection\_name</mark> – Specifies the name of the Collection to be created in the Hyperspace database. You can specify any name as long as it is unique to your Hyperspace Collection.

**Response**

The following response should be received –

`{'status': 'OK', 'code': 200, 'message': 'Collection was successfully created'}`

**Committing a Collection**

After you upload the data, it is required that you commit it, by running the following command to initiate the process of Hyperspace automatically backing up uploaded data periodically. Hyperspace handles data restoration automatically and transparently.

The following command creates a Collection.

{% tabs %}
{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
hyperspace_client.commit(collection_name)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
 hyperspaceClient.commit(collection_name);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
await hyperspaceClient.commit(collection_name);
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Where** –

* <mark style="color:purple;">collection\_name</mark> – Specifies the name of the Collection to be committed to the Hyperspace database.

**Deleting a Collection**

The following command describes how to delete a Collection.

{% tabs %}
{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
hyperspace_client.delete_collection(collection_name)
```

{% endcode %}
{% endtab %}

{% tab title="Untitled" %}
{% code lineNumbers="true" %}

```java
await hyperspaceClient.deleteCollection(collection_name);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
await hyperspaceClient.deleteCollection(collection_name);
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Where** –

* <mark style="color:purple;">collection\_name</mark> – Specifies the name of the Collection to be deleted from the Hyperspace database.

{% hint style="info" %}
You may want to do this in order to save storage space or clean up your space, but please note that this is an irreversible operation.
{% endhint %}

**Clearing a Collection**

The following describes how to clear a Collection, which erases all the data in the Collection.

{% tabs %}
{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
hyperspace_client.clear_collection(collection_name)
```

{% endcode %}
{% endtab %}

{% tab title="Jaba" %}
{% code lineNumbers="true" %}

```javascript
hyperspaceClient.clearCollection(collection_name);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
await hyperspaceClient.clearCollection(collection_name);
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Getting a Collection Scheme**

The following describes how to get a Collection's schema.

{% tabs %}
{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
schema = hyperspace_client.get_schema(collection_name)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
let schema = hyperspace_client.getSchema(collection_name);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
const schema = hyperspace_client.getSchema(collection_name);
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# 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://docs.hyper-space.io/hyperspace-docs/flows/data-collections.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.
