Skip to main content

Collections

Description

Collections are used to organize and group related stacks. Collections can have parent-child relationships with other collections and can contain multiple stacks.

Methods

create

Creates a new collection

Props

NameTypeRequiredDescription
metadataobjectNoAdditional metadata to store with the collection

Returns

Collection - The created collection object

Example

const collection = await client.collections.create({ metadata: { name: 'My Collection' } });

get

Retrieves a specific collection by ID

Props

NameTypeRequiredDescription
idstringYesThe ID of the collection

Returns

Collection | undefined - The collection object if found

Example

const collection = await client.collections.get({ id: '123' });

list

Lists all collections with optional pagination. Works with lastId and limit pagination.

Props

NameTypeRequiredDescription
lastIdstringNoID of the last item for pagination
limitnumberNoMaximum number of items to return

Returns

Collection[] - Array of collection objects

Example

const collections = await client.collections.list({ lastId: '123', limit: 10 });

update

Updates an existing collection

Props

NameTypeRequiredDescription
idstringYesThe ID of the collection to update
metadataobjectNoUpdated metadata for the collection

Returns

Collection - The updated collection object

Example

const collection = await client.collections.update({ id: '123', metadata: { name: 'My Collection' } });

children

children.add

Adds a child collection to a parent collection

Props
NameTypeRequiredDescription
collectionIdstringYesThe ID of the parent collection
childCollectionIdstringYesThe ID of the child collection
Returns

void

Example

await client.collections.children.add({ collectionId: '123', childCollectionId: '456' });

children.list

Lists all child collections of a parent collection

Props
NameTypeRequiredDescription
collectionIdstringYesThe ID of the parent collection
Returns

Collection[] - Array of child collection objects

Example

const children = await client.collections.children.list({ collectionId: '123' });

children.remove

Removes a child collection from a parent collection

Props
NameTypeRequiredDescription
collectionIdstringYesThe ID of the parent collection
childCollectionIdstringYesThe ID of the child collection
Returns

void

Example

await client.collections.children.remove({ collectionId: '123', childCollectionId: '456' });

parents

parents.add

Adds a parent collection to a collection

Props
NameTypeRequiredDescription
collectionIdstringYesThe ID of the child collection
parentCollectionIdstringYesThe ID of the parent collection
Returns

void

Example

await client.collections.parents.add({ collectionId: '123', parentCollectionId: '456' });

parents.list

Lists all parent collections of a collection

Props
NameTypeRequiredDescription
collectionIdstringYesThe ID of the child collection
Returns

Collection[] - Array of parent collection objects

Example

const parents = await client.collections.parents.list({ collectionId: '123' });

parents.remove

Removes a parent collection from a collection

Props
NameTypeRequiredDescription
collectionIdstringYesThe ID of the child collection
parentCollectionIdstringYesThe ID of the parent collection
Returns

void

Example

await client.collections.parents.remove({ collectionId: '123', parentCollectionId: '456' });

stacks

stacks.add

Adds a single stack to a collection

Props
NameTypeRequiredDescription
collectionIdstringYesThe ID of the collection
stackIdstringYesThe ID of the stack to add
Returns

Collection - The updated collection object

Example

const collection = await client.collections.stacks.add({ collectionId: '123', stackId: '456' });

stacks.addMany

Adds multiple stacks to a collection

Props
NameTypeRequiredDescription
collectionIdstringYesThe ID of the collection
stackIdsstring[]YesArray of stack IDs to add
Returns

Collection - The updated collection object

Example

const collection = await client.collections.stacks.addMany({ collectionId: '123', stackIds: ['456', '789'] });

stacks.remove

Removes a stack from a collection

Props
NameTypeRequiredDescription
collectionIdstringYesThe ID of the collection
stackIdstringYesThe ID of the stack to remove
Returns

void

Example

await client.collections.stacks.remove({ collectionId: '123', stackId: '456' });

Types

Collection

Represents a collection object that can contain stacks and have parent-child relationships with other collections.

PropertyTypeDescription
idstringUnique identifier for the collection
metadataanyCustom metadata associated with the collection
createdAtDateTimestamp when the collection was created
updatedAtDateTimestamp when the collection was last updated