#Create a collection with Attributes using Node JS Appwrite SDK

4 messages · Page 1 of 1 (latest)

sly dagger
#

Is there a way to create a collection with the respective attributes?

toxic jolt
sly dagger
#

there are no examples how to create a collection with multiple attributes

for example the below examples shows how to create a collection, but not with attributes

const sdk = require('node-appwrite');

// Init SDK
const client = new sdk.Client();

const databases = new sdk.Databases(client);

client
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
    .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;

const promise = databases.createCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]');

promise.then(function (response) {
    console.log(response);
}, function (error) {
    console.log(error);
});

thou I understand that it has something to do with creating string attributes

const sdk = require('node-appwrite');

// Init SDK
const client = new sdk.Client();

const databases = new sdk.Databases(client);

client
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
    .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;

const promise = databases.createStringAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', 1, false);

promise.then(function (response) {
    console.log(response);
}, function (error) {
    console.log(error);
});
Appwrite

Appwrite is a backend-as-a-service platform that provides developers with all the core APIs required to build any application.

toxic jolt
#
  1. create collection
  2. create attributs one by one