Skip to main content

Create a Key-Value Store

This page explains how to create a new Key-Value Store collection.

Create a Key-Value Store Collection with the Console

Follow these instructions to create a new collection using the GDN console web UI.

  1. Log in to your Macrometa account.

  2. Click Collections.

  3. Click New Collection.

  4. Click Key-Value Store.

  5. Enter information about the collection and then click Create.

    • Name - Required. A unique name to distinguish the collection. Spaces are not allowed.
    • Expiration - Enable expiration. This allows key-value documents to be removed at a certain date and time.
    • Enable Collection stream - Create a stream for this collection. You can do this now or after the collection is created.
    • Wait for sync - Synchronize to disk before completing record creation or update.

Create Key-Value Store Collection with Code

This code example shows how to create a collection for saving the key-value pairs.

  from c8 import C8Client

key = "<your-api-key>"
collection_name = "students"

# Create a connection to gdn
client = C8Client(protocol='https', host='play.paas.macrometa.io', port=443,
apikey=key)

# Create a new collection if it does not exist
if client.has_collection(collection_name):
print("Collection exists")
else:
client.create_collection_kv(name=collection_name)