Label

Label

Source:
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.

Methods

(static) update() → {Promise.<Label.Label>}

Source:
The Update label call is used to update an existing label.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

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))
Returns:
Promise for Label instance
Type
Promise.<Label.Label>

(static) delete() → {Object}

Source:
The Delete label call is used to delete a specific label.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).label('label_uid').delete()
.then((response) => console.log(response.notice))
Returns:
Response Object.
Type
Object

(static) fetch() → {Promise.<Label.Label>}

Source:
The fetch Label returns information about a particular label of a stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).label('label_uid').fetch()
.then((label) => console.log(label))
Returns:
Promise for Label instance
Type
Promise.<Label.Label>

(static) create() → {Promise.<Label.Label>}

Source:
The Create an label call creates a new label.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
const label = {
 name: 'First label',
 content_types: [singlepageCT.content_type.uid]
}
client.stack().label().create({ label })
.then((label) => console.log(label))
Returns:
Promise for Label instance
Type
Promise.<Label.Label>

(static) query(params) → {Array.<Label>}

Source:
Properties:
Name Type Description
params.query Object Queries that you can use to fetch filtered results.
The Query on Label will allow to fetch details of all or specific Label.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack().label().query({ query: { name: 'Label Name' } }).find()
.then((label) => console.log(label))
Parameters:
Name Type Description
params Object URI parameters
Returns:
Array of Label.
Type
Array.<Label>