- Source:
GlobalField defines the structure or schema of a page or a section of your web or mobile property. To create global Fields for your application, you are required to first create a gloabl field. Read more about Global Fields.
Methods
(static) update() → {Promise.<GlobalField.GlobalField>}
- Source:
The Update GlobalField call lets you update the name and description of an existing GlobalField.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).globalField('global_field_uid').fetch()
.then((globalField) => {
globalField.title = 'My New Content Type'
globalField.description = 'Content Type description'
return globalField.update()
})
.then((globalField) => console.log(globalField))
Returns:
Promise for GlobalField instance
- Type
- Promise.<GlobalField.GlobalField>
(static) delete() → {Object}
- Source:
The Delete GlobalField call is used to delete an existing GlobalField permanently from your Stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).globalField('global_field_uid').delete()
.then((response) => console.log(response.notice))
Returns:
Response Object.
- Type
- Object
(static) fetch() → {Promise.<GlobalField.GlobalField>}
- Source:
The fetch GlobalField call fetches GlobalField details.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack({ api_key: 'api_key'}).globalField('global_field_uid').fetch()
.then((globalField) => console.log(globalField))
Returns:
Promise for GlobalField instance
- Type
- Promise.<GlobalField.GlobalField>
(static) create() → {Promise.<GlobalField.GlobalField>}
- Source:
The Create a GlobalField call creates a new globalField in a particular stack of your Contentstack account.
Example
import * as contentstac k from '@contentstack/management'
const client = contentstack.client()
const global_field = {
title: 'First',
uid: 'first',
schema: [{
display_name: 'Name',
uid: 'name',
data_type: 'text'
}]
}
client.stack().globalField().create({ global_field })
.then((globalField) => console.log(globalField))
Returns:
Promise for GlobalField instance
- Type
- Promise.<GlobalField.GlobalField>
(static) query() → {Array.<GlobalField>}
- Source:
The Query on GlobalField will allow to fetch details of all or specific GlobalField
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
client.stack().globalField().query({ query: { name: 'Global Field Name' } }).find()
.then((globalFields) => console.log(globalFields))
Returns:
Array of GlobalField.
- Type
- Array.<GlobalField>
(static) import()
- Source:
The Import a global field call imports a global field into a stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()
const data = {
global_field: 'path/to/file.json',
}
client.stack({ api_key: 'api_key'}).globalField().import(data)
.then((globalField) => console.log(globalField))
Parameters:
Name | Type | Description |
---|---|---|
data.global_field |
String | path to file |