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
Name | Type | Required | Description |
---|---|---|---|
metadata | object | No | Additional 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
Name | Type | Required | Description |
---|---|---|---|
id | string | Yes | The 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
Name | Type | Required | Description |
---|---|---|---|
lastId | string | No | ID of the last item for pagination |
limit | number | No | Maximum 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
Name | Type | Required | Description |
---|---|---|---|
id | string | Yes | The ID of the collection to update |
metadata | object | No | Updated 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
Name | Type | Required | Description |
---|---|---|---|
collectionId | string | Yes | The ID of the parent collection |
childCollectionId | string | Yes | The 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
Name | Type | Required | Description |
---|---|---|---|
collectionId | string | Yes | The 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
Name | Type | Required | Description |
---|---|---|---|
collectionId | string | Yes | The ID of the parent collection |
childCollectionId | string | Yes | The 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
Name | Type | Required | Description |
---|---|---|---|
collectionId | string | Yes | The ID of the child collection |
parentCollectionId | string | Yes | The 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
Name | Type | Required | Description |
---|---|---|---|
collectionId | string | Yes | The 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
Name | Type | Required | Description |
---|---|---|---|
collectionId | string | Yes | The ID of the child collection |
parentCollectionId | string | Yes | The 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
Name | Type | Required | Description |
---|---|---|---|
collectionId | string | Yes | The ID of the collection |
stackId | string | Yes | The 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
Name | Type | Required | Description |
---|---|---|---|
collectionId | string | Yes | The ID of the collection |
stackIds | string[] | Yes | Array 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
Name | Type | Required | Description |
---|---|---|---|
collectionId | string | Yes | The ID of the collection |
stackId | string | Yes | The 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.
Property | Type | Description |
---|---|---|
id | string | Unique identifier for the collection |
metadata | any | Custom metadata associated with the collection |
createdAt | Date | Timestamp when the collection was created |
updatedAt | Date | Timestamp when the collection was last updated |