Factories
Contents
Factories#
ItemFactory#
- class ItemFactory()#
A factory class for item collections
- ItemFactory.ItemFactoryOptions()#
- Arguments
url (
string()
) – Custom URL for collectioncustomParameters (
object()
) – Custom parameters object
- ItemFactory.create(search, project, options)#
Creates the item collection
- Arguments
search (
Model()
) – The search model (this.options.search)project (
Model()
) – The project (this.options.project)options (
ItemFactoryOptions()
) – Additional options
- Returns
Collection – - The items collection
Examples:
var factory = Factories.Collections.Items; var collection = factory.create(this.options.search, this.options.project, options);
- ItemFactory.createFromParams(params, url)#
Creates the item collection from a parameters object
- Arguments
params (
Object()
) – The parameters objecturl (
String()
) – Custom url, if required
- Returns
Collection – - The items collection
Examples:
var factory = Factories.Collections.Items; var collection = factory.createFromParams(this.getCollectionParams());
AggregationsFactory#
- class AggregationsFactory()#
A factory class for item collections
- AggregationsFactory.AggregationsFactoryOptions()#
- Arguments
search (
Model()
) – The search model (this.options.search)project (
Model()
) – The project (this.options.project)content (
String()
) – If fetch is not overriden, specifies the outer aggregation fieldlimit (
String()
) – If fetch is not overriden, specifies size of the aggregationfield (
String()
) – If fetch is not overriden, specifies the inner aggregation fieldaggregate_method (
String()
) – If fetch is not overriden, specifies aggregation method
- AggregationsFactory.create(type, options)#
Creates the aggregations collection
- Arguments
type (
string()
) – Collection type, used for caching so make it unique per widgetextensions (
AggregationsFactoryOptions()
) – Functions and properties in this object will be attached to the created collection prototype
- Returns
Collection – - The aggregations collection
Examples:
var factory = Factories.Collections.Aggregations; var collection = factory.create('MyCollection', this.getCollectionParams());
- AggregationsFactory.createCommunities(type, project, search, limit, communityTypes, options)#
Creates the community aggregations collection
- Arguments
type (
string()
) – Collection type, used for caching so make it unique per widgetextensions (
AggregationsFactoryOptions()
) – Functions and properties in this object will be attached to the created collection prototype
- Returns
Collection – - The aggregations collection
Examples:
var factory = Factories.Collections.Aggregations; var collection = factory.createCommunities('MyCollection', this.getCollectionParams());
- AggregationsFactory.createFacets(type, project, search, limit, fields, options)#
Creates the facets aggregations collection
- Arguments
type (
string()
) – Collection type, used for caching so make it unique per widgetextensions (
AggregationsFactoryOptions()
) – Functions and properties in this object will be attached to the created collection prototype
- Returns
Collection – - The aggregations collection
Examples:
var factory = Factories.Collections.Aggregations; var collection = factory.createFacets('MyCollection', this.getCollectionParams());
FacetsFactory#
- class FacetsFactory()#
A factory class for item collections
- FacetsFactory.FacetsFactoryOptions()#
- Arguments
itemsCollection (
Collection()
) – If passed, links the collection to the item collection updatesnof_facets (
Number()
) – Limits the number of facet values per facetfacet_fields (
Array.
) – Only fetch specific facet fieldsurl (
string()
) – Custom URL passed from custom widgetscustomParameters (
object()
) – Custom parameters object
- FacetsFactory.create(search, project, options)#
Creates the facets collection
- Arguments
search (
Model()
) – The search model (this.options.search)project (
Model()
) – The project (this.options.project)options (
FacetsFactoryOptions()
) – Options
- Returns
Collection – - The items collection
Examples:
var factory = Factories.Collections.Facets; var collection = factory.create(this.options.search, this.options.project);
MockItemFactory#
- class MockItemFactory()#
A factory class for mocked item collections
- MockItemFactory.create(search, project, items=null)#
Creates the mocked item collection, with preloaded data and detached from the backend
- Arguments
search (
Model()
) – The search model (this.options.search)project (
Model()
) – The project (this.options.project)items (
Array.
) – Items to preload the collection with
- Returns
Collection – - The items collection
Examples:
var factory = Factories.Collections.MockItems; var collection = factory.create(this.options.search, this.options.project, [{ title: 'Item title' }]);