Members
(static, constant) comparators
- Source:
Retrieves all available filter comparators for each data type
Example
const {hash, available, types} = await sdk.content.comparators();
console.log(available) // {boolean:[{title:'Is equal to', operator:'equal'...}]}
console.log(hash) // {equal:[{title:'Is equal to', operator:'equal'...}]}
Methods
(static) create(type, input)
- Source:
Create an item
Example
const result = await sdk.content.create('profile', {
firstName:'Mickey',
lastName:'Mouse',
gender:'male',
meta:{
scopes:['61eca4746971e75c1fc670cf'],
}
})
Parameters:
| Name |
Type |
Description |
type |
String
|
The type or definition of the record we want to create |
input |
Object
|
The data for our new record |
(static) delete(id)
- Source:
Delete an item from the database
Example
const result = await sdk.content.delete('61eca4746971e75c1fc670cd')
Parameters:
| Name |
Type |
Description |
id |
String
|
The id of the record we want to delete |
(static) get(id)
- Source:
Get an item from the database, Only fields the user has permission to view will be returned
Example
const result = await sdk.content.get('61eca4746971e75c1fc670cd')
Parameters:
| Name |
Type |
Description |
id |
String
|
The id of the record we want to update |
(static) getFromSlug(slug)
- Source:
Retrieve an item from the database by providing it's 'slug'
Example
const result = await sdk.content.getFromSlug('article:how-to-get-started')
const result = await sdk.content.getFromSlug('car:toyota-landcruiser')
const result = await sdk.content.getFromSlug('article:toyota-landcruiser')
Parameters:
| Name |
Type |
Description |
slug |
String
|
The slug id of the record we want to retrieve
it must be provided as either `(type):(slug)`` or `(definition):(slug)`
(if unsure use the `meta.abs` absolute slug property of the item you are wanting to retrieve). |
(static) glossary(options)
- Source:
Retrieves the glossary of all content types visible to the requesting user.
By default this will include all fields, validation, expressions and other configuration
Example
const { article, profile } = await sdk.content.glossary({hash:true});
Parameters:
| Name |
Type |
Description |
options |
Object
|
Additional options
Properties
| Name |
Type |
Description |
hash |
Boolean
|
Whether to return the data as a keyed object
allowing for fast selection of specific content types, by default will return as an array |
reload |
Boolean
|
Force glossary to reload and not be cached.
If false will retrieve content type data from the in memory cache |
|
(static) list(type, options)
- Source:
Retrieves a list of records matching the provided criteria
Example
sdk.content.list('profile', {
search:'Jim',
page:{
size:50,
index:2,
},
sort:{
key:'age',
direction:'asc',
type:'integer',
},
filter:{
operator:'and',
filters:[{
key:'age',
comparator:'>',
value:5,
}],
},
})
Parameters:
| Name |
Type |
Description |
type |
String
|
The type or definition of records we want to retrieve |
options |
Object
|
The options for our query
Properties
| Name |
Type |
Description |
search |
String
|
Freeform text keywords |
sort |
Object
|
How to sort the results
Properties
| Name |
Type |
Description |
key |
String
|
Which key to sort on |
direction |
String
|
Which direction to sort on |
type |
Object
|
What type of data is being sorted |
|
page |
Object
|
Page configuration
Properties
| Name |
Type |
Description |
size |
Number
|
Page size |
index |
Number
|
Page index |
|
filter |
Object
|
How to filter the results |
|
(static) patch(id, input)
- Source:
Partially update and patch an item, Only fields the user has permission to edit will be updated
Example
const result = await sdk.content.patch('61eca4746971e75c1fc670cd', {
firstName:'Mickey',
gender:'male',
})
Parameters:
| Name |
Type |
Description |
id |
String
|
The id of the record we want to update |
input |
Object
|
The data to update, this will be merged with existing data |
(static) restore(id)
- Source:
Restore a deleted item from the database
Example
const result = await sdk.content.restore('61eca4746971e75c1fc670cd')
Parameters:
| Name |
Type |
Description |
id |
String
|
The id of the record we want to restore |
(static) scopeGlossary(options)
- Source:
Retrieves the scope glossary of all scopes the user can know about. This helps to convert a scope id into a human readable title.
Example
const scopes = await sdk.content.scopeGlossary();
Parameters:
| Name |
Type |
Description |
options |
Object
|
Additional options
Properties
| Name |
Type |
Description |
hash |
Boolean
|
Whether to return the data as a keyed object with each scopes _id as the key
allowing for fast selection of specific scopes, by default will return a structured tree |
reload |
Boolean
|
Force the glossary to reload and not be cached.
If false will retrieve content type data from the in memory cache |
|
(static) update(id, input)
- Source:
Update an item, Only fields the user has permission to view will be returned
Example
const result = await sdk.content.update('61eca4746971e75c1fc670cd', {
firstName:'Minnie',
lastName:'Mouse',
gender:'female',
meta:{
scopes:['61eca4746971e75c1fc670cd'],
}
})
Parameters:
| Name |
Type |
Description |
id |
String
|
The id of the record we want to update |
input |
Object
|
The data to update |
(static) validateField(input, fieldDefinition, options)
- Source:
Checks if a certain input validates against a field definition
Example
const validationResult = await sdk.content.validateField('Johnny Bobbins', {title:'Name', key:'firstName', type:'string', minimum:1, maximum:1, ...});
console.log(validationResult)
// Results in { valid:true }
const validationResult = await sdk.content.validateField('Johnny Bobbins', {title:'Number', key:'number', type:'integer', minimum:1, maximum:1, ...});
console.log(validationResult)
// Results in { valid:false, status:400, message:'Invalid number input for field' }
Parameters:
| Name |
Type |
Description |
input |
Any
|
The input to validate |
fieldDefinition |
Object
|
The field to validate against |
options |
Object
|
Additional options when calling the function |
(static) variables(keys, options)
- Source:
Retrieves all global variables for the current user. This is often used when running custom code in an action.
Example
const { OAUTH_CLIENT_ID, OAUTH_KEY } = await sdk.content.variables();
Parameters:
| Name |
Type |
Description |
keys |
Array
|
Provide specific keys of variables you want to retrieve |
options |
Object
|
Additional options when making the request
Properties
| Name |
Type |
Description |
reload |
Boolean
|
Force variables to reload and not be cached. If false will retrieve any variables that are already known from the in memory cache. |
|