fluro
Version:
Promise based HTTP Fluro client for the browser and node.js
3,174 lines (959 loc) • 63 kB
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>content - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="access.html">access</a><ul class='methods'><li data-type='method'><a href="access.html#.addEventListener">addEventListener</a></li><li data-type='method'><a href="access.html#.can">can</a></li><li data-type='method'><a href="access.html#.canDeleteItem">canDeleteItem</a></li><li data-type='method'><a href="access.html#.canEditItem">canEditItem</a></li><li data-type='method'><a href="access.html#.canKnowOf">canKnowOf</a></li><li data-type='method'><a href="access.html#.canViewItem">canViewItem</a></li><li data-type='method'><a href="access.html#.has">has</a></li><li data-type='method'><a href="access.html#.isAuthor">isAuthor</a></li><li data-type='method'><a href="access.html#.removeAllListeners">removeAllListeners</a></li><li data-type='method'><a href="access.html#.removeEventListener">removeEventListener</a></li><li data-type='method'><a href="access.html#.retrieveActionableRealms">retrieveActionableRealms</a></li><li data-type='method'><a href="access.html#.retrieveCurrentSession">retrieveCurrentSession</a></li><li data-type='method'><a href="access.html#.setDefaultApplication">setDefaultApplication</a></li></ul></li><li><a href="api.html">api</a><ul class='methods'><li data-type='method'><a href="api.html#.delete">delete</a></li><li data-type='method'><a href="api.html#.generateEndpointURL">generateEndpointURL</a></li><li data-type='method'><a href="api.html#.get">get</a></li><li data-type='method'><a href="api.html#.post">post</a></li><li data-type='method'><a href="api.html#.put">put</a></li></ul></li><li><a href="app.device.html">device</a></li><li><a href="asset.html">asset</a><ul class='methods'><li data-type='method'><a href="asset.html#.avatarUrl">avatarUrl</a></li><li data-type='method'><a href="asset.html#.downloadUrl">downloadUrl</a></li><li data-type='method'><a href="asset.html#.filesize">filesize</a></li><li data-type='method'><a href="asset.html#.getUrl">getUrl</a></li><li data-type='method'><a href="asset.html#.imageUrl">imageUrl</a></li><li data-type='method'><a href="asset.html#.playerUrl">playerUrl</a></li><li data-type='method'><a href="asset.html#.posterUrl">posterUrl</a></li><li data-type='method'><a href="asset.html#.typeFromMime">typeFromMime</a></li></ul></li><li><a href="auth.html">auth</a><ul class='methods'><li data-type='method'><a href="auth.html#.addEventListener">addEventListener</a></li><li data-type='method'><a href="auth.html#.changeAccount">changeAccount</a></li><li data-type='method'><a href="auth.html#.getCurrentToken">getCurrentToken</a></li><li data-type='method'><a href="auth.html#.getCurrentUser">getCurrentUser</a></li><li data-type='method'><a href="auth.html#.impersonate">impersonate</a></li><li data-type='method'><a href="auth.html#.login">login</a></li><li data-type='method'><a href="auth.html#.logout">logout</a></li><li data-type='method'><a href="auth.html#.refreshAccessToken">refreshAccessToken</a></li><li data-type='method'><a href="auth.html#.removeAllListeners">removeAllListeners</a></li><li data-type='method'><a href="auth.html#.removeEventListener">removeEventListener</a></li><li data-type='method'><a href="auth.html#.retrieveUserFromResetToken">retrieveUserFromResetToken</a></li><li data-type='method'><a href="auth.html#.sendResetPasswordRequest">sendResetPasswordRequest</a></li><li data-type='method'><a href="auth.html#.set">set</a></li><li data-type='method'><a href="auth.html#.signup">signup</a></li><li data-type='method'><a href="auth.html#.updateUserWithToken">updateUserWithToken</a></li></ul></li><li><a href="cache.html">cache</a><ul class='methods'><li data-type='method'><a href="cache.html#.get">get</a></li><li data-type='method'><a href="cache.html#.reset">reset</a></li></ul></li><li><a href="components.html">components</a><ul class='methods'><li data-type='method'><a href="components.html#.hydrateModel">hydrateModel</a></li></ul></li><li><a href="content.html">content</a><ul class='methods'><li data-type='method'><a href="content.html#.duplicate">duplicate</a></li><li data-type='method'><a href="content.html#.external">external</a></li><li data-type='method'><a href="content.html#.filter">filter</a></li><li data-type='method'><a href="content.html#.form">form</a></li><li data-type='method'><a href="content.html#.get">get</a></li><li data-type='method'><a href="content.html#.getMultiple">getMultiple</a></li><li data-type='method'><a href="content.html#.keys">keys</a></li><li data-type='method'><a href="content.html#.list">list</a></li><li data-type='method'><a href="content.html#.query">query</a></li><li data-type='method'><a href="content.html#.related">related</a></li><li data-type='method'><a href="content.html#.retrieve">retrieve</a></li><li data-type='method'><a href="content.html#.slug">slug</a></li><li data-type='method'><a href="content.html#.submitInteraction">submitInteraction</a></li><li data-type='method'><a href="content.html#.submitPost">submitPost</a></li><li data-type='method'><a href="content.html#.thread">thread</a></li><li data-type='method'><a href="content.html#.values">values</a></li></ul></li><li><a href="date.html">date</a><ul class='methods'><li data-type='method'><a href="date.html#.countdown">countdown</a></li><li data-type='method'><a href="date.html#.dateFromID">dateFromID</a></li><li data-type='method'><a href="date.html#.formatDate">formatDate</a></li><li data-type='method'><a href="date.html#.getAge">getAge</a></li><li data-type='method'><a href="date.html#.groupEventByDate">groupEventByDate</a></li><li data-type='method'><a href="date.html#.isDifferentTimezoneThanUser">isDifferentTimezoneThanUser</a></li><li data-type='method'><a href="date.html#.isMultiDayEvent">isMultiDayEvent</a></li><li data-type='method'><a href="date.html#.localDate">localDate</a></li><li data-type='method'><a href="date.html#.militaryTimestamp">militaryTimestamp</a></li><li data-type='method'><a href="date.html#.readableEventDate">readableEventDate</a></li><li data-type='method'><a href="date.html#.readableEventTime">readableEventTime</a></li><li data-type='method'><a href="date.html#.timeago">timeago</a></li><li data-type='method'><a href="date.html#.timeline">timeline</a></li><li data-type='method'><a href="date.html#.timestampToAmPm">timestampToAmPm</a></li><li data-type='method'><a href="date.html#.timezones">timezones</a></li></ul></li><li><a href="fluro.html">fluro</a></li><li><a href="types.html">types</a><ul class='methods'><li data-type='method'><a href="types.html#.all">all</a></li><li data-type='method'><a href="types.html#.basicTypes">basicTypes</a></li><li data-type='method'><a href="types.html#.get">get</a></li><li data-type='method'><a href="types.html#.mapDefinitionItems">mapDefinitionItems</a></li><li data-type='method'><a href="types.html#.parentType">parentType</a></li><li data-type='method'><a href="types.html#.postableTypes">postableTypes</a></li><li data-type='method'><a href="types.html#.readable">readable</a></li><li data-type='method'><a href="types.html#.reloadTerminology">reloadTerminology</a></li><li data-type='method'><a href="types.html#.retrieve">retrieve</a></li><li data-type='method'><a href="types.html#.subTypes">subTypes</a></li><li data-type='method'><a href="types.html#.term">term</a></li></ul></li><li><a href="utils.html">utils</a><ul class='methods'><li data-type='method'><a href="utils.html#.arrayIDs">arrayIDs</a></li><li data-type='method'><a href="utils.html#.comma">comma</a></li><li data-type='method'><a href="utils.html#.currencySymbol">currencySymbol</a></li><li data-type='method'><a href="utils.html#.errorMessage">errorMessage</a></li><li data-type='method'><a href="utils.html#.extractFromArray">extractFromArray</a></li><li data-type='method'><a href="utils.html#.formatCurrency">formatCurrency</a></li><li data-type='method'><a href="utils.html#.getDefaultValueForField">getDefaultValueForField</a></li><li data-type='method'><a href="utils.html#.getFlattenedFields">getFlattenedFields</a></li><li data-type='method'><a href="utils.html#.getStringID">getStringID</a></li><li data-type='method'><a href="utils.html#.guid">guid</a></li><li data-type='method'><a href="utils.html#.hash">hash</a></li><li data-type='method'><a href="utils.html#.injectScript">injectScript</a></li><li data-type='method'><a href="utils.html#.machineName">machineName</a></li><li data-type='method'><a href="utils.html#.mapParameters">mapParameters</a></li><li data-type='method'><a href="utils.html#.matchInArray">matchInArray</a></li><li data-type='method'><a href="utils.html#.processCardPrioritySort">processCardPrioritySort</a></li></ul></li><li><a href="video.html">video</a><ul class='methods'><li data-type='method'><a href="video.html#.hhmmss">hhmmss</a></li><li data-type='method'><a href="video.html#.readableMilliseconds">readableMilliseconds</a></li><li data-type='method'><a href="video.html#.readableSeconds">readableSeconds</a></li></ul></li></ul>
</nav>
<div id="main">
<h1 class="page-title">content</h1>
<section>
<header>
<h2>
content
</h2>
</header>
<article>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id=".mention"><span class="type-signature">(static) </span>mention<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line222">line 222</a>
</li></ul></dd>
</dl>
<div class="description">
Runs a search from the Fluro server for a specific mentionable user
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>fluro.content.mention('john.smith', {limit:5}, config).then(function(results) {
//Will return a nested array with up to 5 personas
})</code></pre>
<h4 class="name" id=".search"><span class="type-signature">(static) </span>search<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line62">line 62</a>
</li></ul></dd>
</dl>
<div class="description">
Runs a search from the Fluro server and returns the results
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>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'...}]
})</code></pre>
<h4 class="name" id=".type"><span class="type-signature">(static) </span>type<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line141">line 141</a>
</li></ul></dd>
</dl>
<div class="description">
Retrieves a specific definition or data type
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>fluro.content.type('song', options, config).then(function(definition) {
//Will return the definition
})</code></pre>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".duplicate"><span class="type-signature">(static) </span>duplicate<span class="signature">(item)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line1167">line 1167</a>
</li></ul></dd>
</dl>
<div class="description">
This function creates a clean copy of a specified content item
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>fluro.content.duplicate({_id:'5be504eabf33991239599d63'})
.then(function(freshItem) {
//Fresh item is a cleaned duplicate of the original item
})</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>item</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The ID or object representing the item you want to duplicate</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A promise that will be resolved with a cleaned duplicate of the original item
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id=".external"><span class="type-signature">(static) </span>external<span class="signature">(externalID, params)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line414">line 414</a>
</li></ul></dd>
</dl>
<div class="description">
This function returns a single populated item by providing its _external id
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>//Retrieve just the title for item with external id that matches '5be504-eabf33991-239599-d63'
fluro.content.external('5be504-eabf33991-239599-d63', {select:'title'})</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>externalID</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The item's _external id property</td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Extra query string parameters for the request</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A promise that will be resolved with the item or an error
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id=".filter"><span class="type-signature">(static) </span>filter<span class="signature">(typeName, criteria)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line1038">line 1038</a>
</li></ul></dd>
</dl>
<div class="description">
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)
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>//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
})</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>typeName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The type or definition name of the content you want to retrieve</td>
</tr>
<tr>
<td class="name"><code>criteria</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The criteria used to filter the results</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A promise that will be resolved with an array of all results
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id=".form"><span class="type-signature">(static) </span>form<span class="signature">(id, options)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line608">line 608</a>
</li></ul></dd>
</dl>
<div class="description">
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'
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>//Retrieve a form ('58dca23c21428d2d045a1cf7') in testing mode
fluro.content.form('58dca23c21428d2d045a1cf7', {testing:true})</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The id of the form to retrieve</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Extra options for the request
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>testing</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Whether to load the form in testing mode or not</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A promise that will be resolved with the form or an error
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id=".get"><span class="type-signature">(static) </span>get<span class="signature">(id, params)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line357">line 357</a>
</li></ul></dd>
</dl>
<div class="description">
This function returns a single populated item by providing its _id
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>//Retrieve just the title for item '5be504eabf33991239599d63'
fluro.content.get('5be504eabf33991239599d63', {select:'title'})</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The item's _id</td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Extra query string parameters for the request</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A promise that will be resolved with the item or an error
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id=".getMultiple"><span class="type-signature">(static) </span>getMultiple<span class="signature">(typeName, ids, options)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line1068">line 1068</a>
</li></ul></dd>
</dl>
<div class="description">
This function makes it easy to retrieve the full content items for a specified selection of ids
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>fluro.content.getMultiple(['5be504eabf33991239599d63', '5be504eabf33721239599d83'])
.then(function(items) {
//Returns the full content items
})</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>typeName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The type or definition name of the content you want to retrieve</td>
</tr>
<tr>
<td class="name"><code>ids</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">The ids of the content you want to retrieve</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">extra options for the request
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>select</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">specify fields you want to retrieve for the items. If blank will return the full object</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A promise that will be resolved with an array of possible keys
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id=".keys"><span class="type-signature">(static) </span>keys<span class="signature">(ids, options)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line1113">line 1113</a>
</li></ul></dd>
</dl>
<div class="description">
This function makes it easy to retrieve all distinct keys for a specified selection of ids
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>fluro.content.keys(['5be504eabf33991239599d63']).then(function(values) {
//Would return ['firstName', 'lastName', 'title', 'tags', 'realms']
})</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>ids</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">The ids you want to retrieve keys for</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">extra options and query parameters for the http request</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A promise that will be resolved with an array of possible keys
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id=".list"><span class="type-signature">(static) </span>list<span class="signature">(typeName, options)</span><span class="type-signature"> → {Object}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line981">line 981</a>
</li></ul></dd>
</dl>
<div class="description">
This function creates an instance of a FluroContentListService
this then becomes a service that can be used to retrieve filtered data from the server
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>//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')});</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>typeName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The type or definition name of the content you want to retrieve</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Extra options for creating the service
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>criteria</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The filter criteria for specifying which content items should be returned
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>sort</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The sorting configuration for the results</td>
</tr>
<tr>
<td class="name"><code>allDefinitions</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="description last">Whether to include all defined types if a basic type is used as the typeName</td>
</tr>
<tr>
<td class="name"><code>filter</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">the fluro filter configuration for filtering returned results</td>
</tr>
<tr>
<td class="name"><code>search</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">A basic keyword search for filtering results</td>
</tr>
<tr>
<td class="name"><code>startDate</code></td>
<td class="type">
<span class="param-type">Date</span>
</td>
<td class="description last">Used in conjunction with endDate to crop results to a relevant date period</td>
</tr>
<tr>
<td class="name"><code>endDate</code></td>
<td class="type">
<span class="param-type">Date</span>
</td>
<td class="description last">Used in conjunction with startDate to crop results to a relevant date period</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>perPage</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The number of items to retrieve per page</td>
</tr>
<tr>
<td class="name"><code>pageIndex</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The starting page to load from the list</td>
</tr>
<tr>
<td class="name"><code>cumulative</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Whether new page items should append to the results or replace the results</td>
</tr>
<tr>
<td class="name"><code>cacheKey</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">A cache id that can be used to refresh cached results</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A new instance of a FluroContentListService
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id=".query"><span class="type-signature">(static) </span>query<span class="signature">(queryID, options)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line296">line 296</a>
</li></ul></dd>
</dl>
<div class="description">
A helper function for retrieving the results of a specified query
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>queryID</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The id of the query you want to run</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The options for the query
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The query string parameters for the query that will be mapped ?one=value&two=value</td>
</tr>
<tr>
<td class="name"><code>variables</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Any query variables you wish to inject each key will be mapped ?variables[key]=value</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A promise that will be resolved with the results or an error
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id=".related"><span class="type-signature">(static) </span>related<span class="signature">(id, params)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line547">line 547</a>
</li></ul></dd>
</dl>
<div class="description">
This function returns a list of related items
That either reference the specified item or are referenced by the provided item
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>//Retrieve some related items for '5be504eabf33991239599d63'
fluro.content.related('5be504eabf33991239599d63', {select:'title'})</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The item to find related content for</td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Extra query string parameters for the request</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A promise that will be resolved with an array of related items
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id=".retrieve"><span class="type-signature">(static) </span>retrieve<span class="signature">(criteria, options)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line501">line 501</a>
</li></ul></dd>
</dl>
<div class="description">
A helper function for retrieving the results of a dynamic query
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>//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'})</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>criteria</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The query criteria</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Extra options and parameters</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A promise that will be resolved with the results or an error
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id=".slug"><span class="type-signature">(static) </span>slug<span class="signature">(slug, params)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line457">line 457</a>
</li></ul></dd>
</dl>
<div class="description">
This function returns a single populated item by providing its slug
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>//Retrieve just the title for item with the slug 'my-article'
fluro.content.slug('my-article', {select:'title'})</code></pre>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>slug</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">The item's slug value</td>
</tr>
<tr>
<td class="name"><code>params</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Extra query string parameters for the request</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
A promise that will be resolved with the item or an error
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id=".submitInteraction"><span class="type-signature">(static) </span>submitInteraction<span class="signature">(definitionName, data, options)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="fluro.content.js.html">fluro.content.js</a>, <a href="fluro.content.js.html#line666">line 666</a>
</li></ul></dd>
</dl>
<div class="description">
This function makes it easy to submit form interactions via the Fluro API
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>/