Create a Redis Mode Collection
This page explains how to create a new Document collection.
- Web Console
- Python SDK
- Javascript SDK
- REST API
- CLI
Follow these instructions to create a new collection using the GDN console web UI.
- Log in to your Macrometa account.
- Click Data > Collections.
- Click New Collection.
- Click Redis Mode.
- Enter a Collection Name then click Create.
The below example shows the steps for connecting a fabric and then creating a collection called employees.
  # Simple Approach
  client = C8Client(protocol='https', host='play.paas.macrometa.io', port=443,
                          email='nemo@nautilus.com', password='xxxxx',
                          geofabric='_system')
  client.create_collection(name='employees')
const jsc8 = require("jsc8");
// Email and password to authenticate client instance
const email = "nemo@nautilus.com";
const password = "xxxxxx";
const fabric = "_system";
const collectionName = "employees";
const client = new jsc8({
  url: "https://play.paas.macrometa.io",
  fabricName: fabric
});
// Or use one of the following authentication methods and remove the commenting.
// Create an authenticated instance with a JWT token.
// const clientUsingJwt = new jsc8({url: "https://play.paas.macrometa.io" , token: "XXXX" , fabricName: fabric});
// Create an authenticated instance with an API key.
// const clientUsingApiKey = new jsc8({url: "https://play.paas.macrometa.io" , apiKey: "XXXX" , fabricName: fabric });
function messageHandler (error) {
  const message = {
    "StatusCode ": error.statusCode,
    "ErrorMessage ": error.message,
    "ErrorNum ": error.errorNum
  };
  console.log(message);
}
async function createCollection () {
  await client
    .login(email, password)
    .then((e) => console.log("1. User authentication done!"))
    .catch((error) => error);
  console.log("2. Creating collection employees in " + fabric + " fabric");
  await client
    .createCollection(collectionName, {
      stream: true,
      waitForSync: false,
      isLocal: false
    })
    .then((collectionDetails) => {
      console.log(
        "Collection " + collectionDetails.name + " created successfully"
      );
      console.log(collectionDetails);
    })
    .catch((error) => messageHandler(error));
}
createCollection()
  .then()
  .catch((error) => console.log(error));
Use our interactive API Reference with code generation in 18 programming languages to Create a Document Collection.
Use the gdnsl collection CLI command to create a document collection.