eneszh
v1v2
InceptionDB
Lambda
Files
Config
InstantLogs
Tailon

Managing Collections


Creating a Collection

To create a collection, you can use the following curl command:

1curl -X POST "https://example.com/v1/databases/719e9421-e6e9-42b6-b9b7-b580e532b9d5/collections" \
2-H "Api-Key: 1abbe476-6ad6-4b97-9cca-6deb6ab2901d" \
3-H "Api-Secret: 4bda6d52-762b-4e5d-bed7-85614c13b8bf" \
4-d '{
5    "name": "my-collection"
6}'

The HTTP request for creating a collection would look like this:

1POST /v1/databases/719e9421-e6e9-42b6-b9b7-b580e532b9d5/collections HTTP/1.1
2Host: example.com
3Api-Key: 1abbe476-6ad6-4b97-9cca-6deb6ab2901d
4Api-Secret: 4bda6d52-762b-4e5d-bed7-85614c13b8bf
5Content-Type: application/json
6
7{
8    "name": "my-collection"
9}

Deleting a Collection

To delete a collection, use the following curl command:

1curl -X POST "https://example.com/v1/databases/dc992d92-c146-448b-a17d-e94614aff740/collections/my-collection:dropCollection" \
2-H "Api-Key: 271ba1e6-87b5-4d0f-84a0-a3d1178d1356" \
3-H "Api-Secret: 5346a7cf-6743-49eb-921b-6e977cf11e36"

The HTTP request for deleting a collection would look like this:

1POST /v1/databases/dc992d92-c146-448b-a17d-e94614aff740/collections/my-collection:dropCollection HTTP/1.1
2Host: example.com
3Api-Key: 271ba1e6-87b5-4d0f-84a0-a3d1178d1356
4Api-Secret: 5346a7cf-6743-49eb-921b-6e977cf11e36

Creating a Collection Implicitly

When Inserting Documents

Collections are created implicitly when you insert documents into them. For example:

Insert One Document

1curl -X POST "https://example.com/v1/databases/436a4499-e9f0-4aaf-9f82-fe2a2e22c3f0/collections/my-collection:insert" \
2-H "Api-Key: ea34c657-4125-4527-8cd1-630b33f50b42" \
3-H "Api-Secret: a30baf65-c9be-4231-92bc-6f04442142c9" \
4-d '{
5    "address": "Elm Street 11",
6    "id": "my-id",
7    "name": "Fulanez"
8}'

The HTTP request would be:

 1POST /v1/databases/436a4499-e9f0-4aaf-9f82-fe2a2e22c3f0/collections/my-collection:insert HTTP/1.1
 2Host: example.com
 3Api-Key: ea34c657-4125-4527-8cd1-630b33f50b42
 4Api-Secret: a30baf65-c9be-4231-92bc-6f04442142c9
 5Content-Type: application/json
 6
 7{
 8    "address": "Elm Street 11",
 9    "id": "my-id",
10    "name": "Fulanez"
11}

Insert Multiple Documents

 1curl -X POST "https://example.com/v1/databases/7b7d79de-d7c7-47b9-8662-e124be300d3d/collections/my-collection:insert" \
 2-H "Api-Key: e609f9ce-9f15-4649-b57c-5e9709e5bcca" \
 3-H "Api-Secret: 19e7a8e9-4cc6-4814-ad3e-c33af518086a" \
 4-d '{
 5    "id":"1",
 6    "name":"Alfonso"
 7}
 8{
 9    "id":"2",
10    "name":"Gerardo"
11}
12{
13    "id":"3",
14    "name":"Alfonso"
15}'

The HTTP request would be:

 1POST /v1/databases/7b7d79de-d7c7-47b9-8662-e124be300d3d/collections/my-collection:insert HTTP/1.1
 2Host: example.com
 3Api-Key: e609f9ce-9f15-4649-b57c-5e9709e5bcca
 4Api-Secret: 19e7a8e9-4cc6-4814-ad3e-c33af518086a
 5Content-Type: application/json
 6
 7{
 8    "id":"1",
 9    "name":"Alfonso"
10}
11{
12    "id":"2",
13    "name":"Gerardo"
14}
15{
16    "id":"3",
17    "name":"Alfonso"
18}

When Creating an Index

Creating an index can also implicitly create a collection. For example:

1curl -X POST "https://example.com/v1/databases/c4e4ac96-5001-4465-b22e-57e971ecc01f/collections/my-collection:createIndex" \
2-H "Api-Key: 4469ae2e-f4d2-4c58-ad03-d34b97957f3a" \
3-H "Api-Secret: aa7d2784-50b7-4846-be77-d7609034ab22" \
4-d '{
5    "field": "id",
6    "name": "my-index-id",
7    "sparse": true,
8    "type": "map"
9}'

The HTTP request would be:

 1POST /v1/databases/c4e4ac96-5001-4465-b22e-57e971ecc01f/collections/my-collection:createIndex HTTP/1.1
 2Host: example.com
 3Api-Key: 4469ae2e-f4d2-4c58-ad03-d34b97957f3a
 4Api-Secret: aa7d2784-50b7-4846-be77-d7609034ab22
 5Content-Type: application/json
 6
 7{
 8    "field": "id",
 9    "name": "my-index-id",
10    "sparse": true,
11    "type": "map"
12}

This document explains how to manage collections, including creating, deleting, and the various implicit methods of creation. You can download this document in Markdown format using the link below:

Download Managing Collections Document