ContentType

ContentType

Source:
Content type defines the structure or schema of a page or a section of your web or mobile property. To create content for your application, you are required to first create a content type, and then create entries using the content type. Read more about Content Types.

Methods

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

Source:
The Update ContentType call lets you update the name and description of an existing ContentType. You can also update the JSON schema of a content type, including fields and different features associated with the content type.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').fetch()
.then((contentType) => {
 contentType.title = 'My New Content Type'
 contentType.description = 'Content Type description'
 return contentType.update()
})
.then((contentType) => console.log(contentType))
Returns:
Promise for ContentType instance
Type
Promise.<ContentType.ContentType>

(static) delete() → {Object}

Source:
The Delete ContentType call is used to delete an existing ContentType permanently from your Stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

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

(static) fetch(version) → {Promise.<ContentType.ContentType>}

Source:
The fetch ContentType call fetches ContentType details.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').fetch()
.then((contentType) => console.log(contentType))
Parameters:
Name Type Description
version Int Enter the unique ID of the content type of which you want to retrieve the details. The UID is generated based on the title of the content type. The unique ID of a content type is unique across a stack.
Returns:
Promise for ContentType instance
Type
Promise.<ContentType.ContentType>

entry(uid) → {ContenType}

Source:
Content type defines the structure or schema of a page or a section of your web or mobile property.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).contentType('content_type_uid').entry('entry_uid').fetch()
.then((contentType) => console.log(contentType))
Parameters:
Name Type Description
uid String The UID of the ContentType you want to get details.
Returns:
Instace of ContentType.
Type
ContenType

(static) generateUid(name)

Source:
The Create a content type call creates a new content type in a particular stack of your Contentstack account.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
const contentType = client.stack().contentType()
const contentTypeName = 'My New contentType'
const content_type = {
  name: name,
  uid: contentType.generateUid(name)
}
contentType
.create({ content_type })
.then((contenttype) => console.log(contenttype))
Parameters:
Name Type Description
name * Name for content type you want to create.

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

Source:
The Create a content type call creates a new content type in a particular stack of your Contentstack account.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
const content_type = {name: 'My New contentType'}
client.stack().contentType().create({ content_type })
.then((contentType) => console.log(contentType))
Returns:
Promise for ContentType instance
Type
Promise.<ContentType.ContentType>

(static) query(include_count) → {Array.<ContentType>}

Source:
The Query on Content Type will allow to fetch details of all or specific Content Type
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).contentType().query({ query: { name: 'Content Type Name' } }).find()
.then((contentTypes) => console.log(contentTypes))
Parameters:
Name Type Description
include_count Boolean Set this to 'true' to include in response the total count of content types available in your stack.
Returns:
Array of ContentTyoe.
Type
Array.<ContentType>

(static) import()

Source:
The Import a content type call imports a content type into a stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

const data = {
 content_type: 'path/to/file.json',
}
client.stack({ api_key: 'api_key'}).contentType().import(data)
.then((contentType) => console.log(contentType))
Parameters:
Name Type Description
data.content_type String path to file