> For the complete documentation index, see [llms.txt](https://simpldb.js.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simpldb.js.org/documentation/database/createcollection.md).

# .createCollection()

### createCollection(name, defaultValues)

| **Parameter** | **Default** | **Description**                                                                                                                                       |
| ------------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| name          |             | <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></p><p>The name for the collection</p> |
| defaultValues |     `{}`    | <p><a href="https://simpldb.gitbook.io/docs/types-and-interfaces/data">Data</a> (optional)</p><p>Default values for omitted keys</p>                  |

| **Returns**                                | **Description**    |
| ------------------------------------------ | ------------------ |
| [Collection](/documentation/collection.md) | The new collection |

####

```javascript
const Users = db.createCollection('users');
```

With default values:

```javascript
const People = db.createCollection('people', {
  name: 'Unnamed person',
  hobbies: []
});
```

With incrementable properties:

{% hint style="info" %}
Incrementable properties were added in the version 2.6.0.

They are used to assign an automatic value to an entry from the collection, incrementing its value when a new entry is inserted into the collection.

To represent an incrementable property, you must put a dollar sign (`$`) before the property name and provide its initial value. The dollar sign will not appear in the entry's properties (ex.: `$id` will set a property named `id`).
{% endhint %}

{% hint style="warning" %}
Incrementable properties only work with values of type [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number).
{% endhint %}

{% hint style="danger" %}
The Typescript typings for incrementable properties are not yet properly working as of version 2.13.0.
{% endhint %}

```javascript
const People = db.createCollection('people', {
  $id: 0, // Incrementable property, starting with the value 0
  name: 'Unnamed person',
  hobbies: []
})
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://simpldb.js.org/documentation/database/createcollection.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.
