Members
(static) mention
- Source:
Runs a search from the Fluro server for a specific mentionable user
Example
fluro.content.mention('john.smith', {limit:5}, config).then(function(results) {
//Will return a nested array with up to 5 personas
})
(static) search
- Source:
Runs a search from the Fluro server and returns the results
Example
fluro.content.search('Wonder', {limit:5, types:['song', 'album', 'tag']}).then(function(results) {
//Will return a nested array with up to 5 results for each type
//[{_type:'Song', results:[{title:"Wonder"...}]}, {_type:'Album', results:[{title:"Wonder"...}]}]
})
fluro.content.search('Wonder', {limit:5}).then(function(results) {
//Will return an array of up to 5 items the user has access to view that match the search terms
//[{title:"Wonder", _type:'article', definition:'song'...}, {title:"Wonder", _type:'article', definition:'album'...}]
})
(static) type
- Source:
Retrieves a specific definition or data type
Example
fluro.content.type('song', options, config).then(function(definition) {
//Will return the definition
})
Methods
(static) duplicate(item) → {Promise}
- Source:
This function creates a clean copy of a specified content item
Example
fluro.content.duplicate({_id:'5be504eabf33991239599d63'})
.then(function(freshItem) {
//Fresh item is a cleaned duplicate of the original item
})
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The ID or object representing the item you want to duplicate |
Returns:
A promise that will be resolved with a cleaned duplicate of the original item
- Type
- Promise
(static) external(externalID, params) → {Promise}
- Source:
This function returns a single populated item by providing its _external id
Example
//Retrieve just the title for item with external id that matches '5be504-eabf33991-239599-d63'
fluro.content.external('5be504-eabf33991-239599-d63', {select:'title'})
Parameters:
Name | Type | Description |
---|---|---|
externalID |
String | The item's _external id property |
params |
Object | Extra query string parameters for the request |
Returns:
A promise that will be resolved with the item or an error
- Type
- Promise
(static) filter(typeName, criteria) → {Promise}
- Source:
This function makes it easy to retrieve a large filtered list of content matching certain criteria
Only the relevant fields will be returned that allows you to paginate and populate content with the
fluro.content.getMultiple() function
for more information please see the REST API endpoint documentation here (https://developers.fluro.io/#filter-content)
Example
//How to sort the results
var sort = {
key:'title',
direction:'asc',
type:'string',
}
//If you want to filter by search keywords
var search = 'Any keywords you want to search for'
//If you want to crop results to within a certain timeframe
var startDate;// = new Date();
var endDate;// = new Date()
//For more complex AND/OR filtering
var filter = {
operator:'and',
filters:[
{
key:'status',
comparator:'in',
values:['active'],
}
]
}
var criteria = {
search,
sort,
startDate,
endDate,
filter,
}
fluro.content.filter('event', criteria)
.then(function(results) {
//Returns all results with the basic fields
})
Parameters:
Name | Type | Description |
---|---|---|
typeName |
String | The type or definition name of the content you want to retrieve |
criteria |
Object | The criteria used to filter the results |
Returns:
A promise that will be resolved with an array of all results
- Type
- Promise
(static) form(id, options) → {Promise}
- Source:
This function returns an interaction definition via the public 'form' API endpoint
This will only result successfully if the definition requested has the definition of 'form' and has the status of 'active'
Example
//Retrieve a form ('58dca23c21428d2d045a1cf7') in testing mode
fluro.content.form('58dca23c21428d2d045a1cf7', {testing:true})
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
id |
String | The id of the form to retrieve | ||||||
options |
Object | Extra options for the request
Properties
|
Returns:
A promise that will be resolved with the form or an error
- Type
- Promise
(static) get(id, params) → {Promise}
- Source:
This function returns a single populated item by providing its _id
Example
//Retrieve just the title for item '5be504eabf33991239599d63'
fluro.content.get('5be504eabf33991239599d63', {select:'title'})
Parameters:
Name | Type | Description |
---|---|---|
id |
String | The item's _id |
params |
Object | Extra query string parameters for the request |
Returns:
A promise that will be resolved with the item or an error
- Type
- Promise
(static) getMultiple(typeName, ids, options) → {Promise}
- Source:
This function makes it easy to retrieve the full content items for a specified selection of ids
Example
fluro.content.getMultiple(['5be504eabf33991239599d63', '5be504eabf33721239599d83'])
.then(function(items) {
//Returns the full content items
})
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
typeName |
String | The type or definition name of the content you want to retrieve | ||||||
ids |
Array | The ids of the content you want to retrieve | ||||||
options |
Object | extra options for the request
Properties
|
Returns:
A promise that will be resolved with an array of possible keys
- Type
- Promise
(static) keys(ids, options) → {Promise}
- Source:
This function makes it easy to retrieve all distinct keys for a specified selection of ids
Example
fluro.content.keys(['5be504eabf33991239599d63']).then(function(values) {
//Would return ['firstName', 'lastName', 'title', 'tags', 'realms']
})
Parameters:
Name | Type | Description |
---|---|---|
ids |
Array | The ids you want to retrieve keys for |
options |
Object | extra options and query parameters for the http request |
Returns:
A promise that will be resolved with an array of possible keys
- Type
- Promise
(static) list(typeName, options) → {Object}
- Source:
This function creates an instance of a FluroContentListService
this then becomes a service that can be used to retrieve filtered data from the server
Example
//How to sort the results
var sort = {
key:'title',
direction:'asc',
type:'string',
}
//If you want to filter by search keywords
var search = 'Any keywords you want to search for'
//If you want to crop results to within a certain timeframe
var startDate;// = new Date();
var endDate;// = new Date()
//For more complex AND/OR filtering
var filter = {
operator:'and',
filters:[
{
key:'status',
comparator:'in',
values:['active'],
}
]
}
var criteria = {
search,
sort,
startDate,
endDate,
filter,
}
var dataBucket = fluro.content.list('event', {
perPage: 2,
criteria,
});
var isLoading = dataBucket.loading;
var allItems = dataBucket.items;
var pageItems = dataBucket.page;
var currentPage = dataBucket.pageIndex;
dataBucket.nextPage();
dataBucket.previousPage();
dataBucket.reloadCurrentPage();
dataBucket.addEventListener('items', function(results) {});
dataBucket.addEventListener('error', function(err) { console.log('an error occurred')});
dataBucket.addEventListener('totalPages', function() { console.log('the number of pages changed')});
dataBucket.addEventListener('loadingFilter', function() { console.log('filter is reloading')});
dataBucket.addEventListener('loadingPage', function() { console.log('the page is reloading')});
dataBucket.addEventListener('page', function() { console.log('the current page was updated')});
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
typeName |
String | The type or definition name of the content you want to retrieve | |||||||||||||||||||||||||||||||||||||||
options |
Object | Extra options for creating the service
Properties
|
Returns:
A new instance of a FluroContentListService
- Type
- Object
(static) query(queryID, options) → {Promise}
- Source:
A helper function for retrieving the results of a specified query
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
queryID |
String | The id of the query you want to run | |||||||||
options |
Object | The options for the query
Properties
|
Returns:
A promise that will be resolved with the results or an error
- Type
- Promise
(static) related(id, params) → {Promise}
- Source:
This function returns a list of related items
That either reference the specified item or are referenced by the provided item
Example
//Retrieve some related items for '5be504eabf33991239599d63'
fluro.content.related('5be504eabf33991239599d63', {select:'title'})
Parameters:
Name | Type | Description |
---|---|---|
id |
String | The item to find related content for |
params |
Object | Extra query string parameters for the request |
Returns:
A promise that will be resolved with an array of related items
- Type
- Promise
(static) retrieve(criteria, options) → {Promise}
- Source:
A helper function for retrieving the results of a dynamic query
Example
//Find all events that have a status of active or archived where the endDate is greater than or equal to now and return the titles
fluro.content.retrieve({_type:'event', status:{$in:['active', 'archived']}, endDate:{$gte:"date('now')"}}}, {select:'title'})
Parameters:
Name | Type | Description |
---|---|---|
criteria |
Object | The query criteria |
options |
Object | Extra options and parameters |
Returns:
A promise that will be resolved with the results or an error
- Type
- Promise
(static) slug(slug, params) → {Promise}
- Source:
This function returns a single populated item by providing its slug
Example
//Retrieve just the title for item with the slug 'my-article'
fluro.content.slug('my-article', {select:'title'})
Parameters:
Name | Type | Description |
---|---|---|
slug |
String | The item's slug value |
params |
Object | Extra query string parameters for the request |
Returns:
A promise that will be resolved with the item or an error
- Type
- Promise
(static) submitInteraction(definitionName, data, options) → {Promise}
- Source:
This function makes it easy to submit form interactions via the Fluro API
Example
//Retrieve some related items for '5be504eabf33991239599d63'
fluro.content.submitInteraction('5be504eabf33991239599d63', 'comment', {data:{customField:'My message'}}, {reply:'5be504eabf33991239599d63'})
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
definitionName |
String | the definition of the form you want to submit eg. 'supportRequest' or 'contactUs'... | ||||||
data |
Object | The interaction data to submit | ||||||
options |
Object | Extra options for the request
Properties
|
Returns:
A promise that will be resolved with an array of related items
- Type
- Promise
(static) submitPost(target, definitionName, data, options) → {Promise}
- Source:
This function makes it easy to create and attach a post to a specified piece of fluro content
Example
//Retrieve some related items for '5be504eabf33991239599d63'
fluro.content.submitPost('5be504eabf33991239599d63', 'comment', {data:{customField:'My message'}}, {reply:'5be504eabf33991239599d63'})
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
target |
String | The ID of the item to attach this post to | ||||||
definitionName |
String | the definition type of the post you want to create eg. 'note' or 'comment'... | ||||||
data |
Object | The post content to create | ||||||
options |
Object | Extra options for the request
Properties
|
Returns:
A promise that will be resolved with an array of related items
- Type
- Promise
(static) thread(target, definitionName, data, options) → {Promise}
- Source:
This function makes it easy to retrieve the current thread of posts attached to a specific
item
Example
//Retrieve the current post thread of all 'comments' attached to a specific content
fluro.content.thread('5be504eabf33991239599d63', 'comment', {data:{customField:'My message'}}, {reply:'5be504eabf33991239599d63'})
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
target |
String | The ID of the item to attach this post to | ||||||
definitionName |
String | the definition type of the post you want to create eg. 'note' or 'comment'... | ||||||
data |
Object | The post content to create | ||||||
options |
Object | Extra options for the request
Properties
|
Returns:
A promise that will be resolved with an array of related items
- Type
- Promise
(static) values(ids, key) → {Promise}
- Source:
This function makes it easy to retrieve all distinct values for a specified field key
for a specified subset of items from the server, for instance if you wanted to retrieve all possible 'firstName' values from
a selection of content ids
Example
fluro.content.values(['5be504eabf33991239599d63'], 'firstName').then(function(values) {
//Would return ['Frank', 'Lucy', 'Marissa']
})
Parameters:
Name | Type | Description |
---|---|---|
ids |
Array | The ids you want to retrieve values for |
key |
String | the key of the field you want to retrieve the values for |
Returns:
A promise that will be resolved with an array of possible values
- Type
- Promise