Labels
Labels
Labels allow you to group a collection of content within a stack. Using labels you can group content types that need to work together. Read more about Labels.
update
The Update label call is used to update an existing label.
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).label('label_uid')
.fetch()
.then((label) => {
label.name = 'My New Content Type'
return label.update()
})
.then((label) => console.log(label))delete
The Delete label call is used to delete a specific label.
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).label('label_uid').delete()
.then((response) => console.log(response.notice))fetch
The fetch Label returns information about a particular label of a stack.
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).label('label_uid').fetch()
.then((label) => console.log(label))create
The Create a label call creates a new label.
| Name | Type | Description |
|---|---|---|
| params.label | Object | The label details you want to create with ContentType uid list. |
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
const label = {
name: 'First label',
content_types: ['content_type_uid']
}
client.stack({ api_key: 'api_key'}).label()
.create({ label })
.then((label) => console.log(label))query
The Query on Label will allow to fetch details of all or specific Label.
| Name | Type | Description |
|---|---|---|
| params.include_count | boolean | The include_count parameter includes the count of total number of label in your stack, along with the details of each label. |
| params.limit | number | The limit parameter will return a specific number of label in the output. |
| params.skip | number | The skip parameter will skip a specific number of label in the response. |
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client.stack({ api_key: 'api_key'}).label()
.query({ query: { name: 'Label Name' } }).find()
.then((label) => console.log(label))