content

fluro. content

new content(fluro)

Source:
Creates a new FluroContent instance. This module provides a number of helper functions for Creating, Reading, Updating and Deleting content via the Fluro API
Parameters:
Name Type Description
fluro FluroCore A reference to the parent instance of the FluroCore module. This module is usually created by a FluroCore instance that passes itself in as the first argument.

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) 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
Name Type Description
testing Object Whether to load the form in testing mode or not
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) 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) 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
Name Type Description
params Object The query string parameters for the query that will be mapped ?one=value&two=value
variables Object Any query variables you wish to inject each key will be mapped ?variables[key]=value
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
Name Type Description
reply Object The id of the post to reply to (If threaded conversation)
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
Name Type Description
reply Object The id of the post to reply to (If threaded conversation)
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
Name Type Description
reply Object The id of the post to reply to (If threaded conversation)
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