Class: View

View

new View(name, queryopt, optionsopt)

Creates a new view instance.
Parameters:
Name Type Attributes Description
name String The name of the view.
query Object <optional>
The view's query.
options Object <optional>
An options object.
Source:

Methods

(static) isLinked() → {Boolean}

Checks if the instance is data-bound to any DOM elements.
Source:
Returns:
True if linked, false if not.
Type
Boolean
Data-binds the view data to the elements matched by the passed selector.
Parameters:
Name Type Attributes Description
outputTargetSelector String The jQuery element selector to select the element into which the data-bound rendered items will be placed. All existing HTML will be removed from this element.
templateSelector String | Object This can either be a jQuery selector identifying which template element to get the template HTML from that each item in the view's data will use when rendering to the screen, or you can pass an object with a template key containing a string that represents the HTML template such as: { template: '
{{:name}}
' }
options Object <optional>
An options object.wd
Source:
See:
  • unlink
Returns:
Type
View
Removes a previously set-up data-binding via the link() method.
Parameters:
Name Type Description
outputTargetSelector String The jQuery target selector.
templateSelector String The jQuery template selector.
Source:
See:
  • link
Returns:
Type
View

_triggerIndexOf()

Source:
See:
  • Mixin.Triggers::_triggerIndexOf()

addLinkIO()

Source:
See:
  • Mixin.Triggers::addLinkIO()

addTrigger()

Source:
See:
  • Mixin.Triggers::addTrigger()

count() → {Number}

Returns the number of documents currently in the view.
Source:
Returns:
Type
Number

data() → {Collection}

Returns the non-transformed data the view holds as a collection reference.
Source:
Returns:
The non-transformed collection reference.
Type
Collection

data() → {Collection}

Gets the module's internal data collection.
Source:
Returns:
Type
Collection

deferEmit()

Emits an event.
Source:
See:
  • Mixin.Events::deferEmit()

distinct(key, queryopt, optionsopt) → {Array}

Find the distinct values for a specified field across a single collection and returns the results in an array.
Parameters:
Name Type Attributes Description
key String The field path to return distinct values for e.g. "person.name".
query Object <optional>
The query to use to filter the documents used to return values from.
options Object <optional>
The query options to use when running the query.
Source:
Returns:
Type
Array

drop() → {boolean}

Drops a view and all it's stored data from the database.
Source:
Returns:
True on success, false on failure.
Type
boolean

emit()

Emits an event.
Source:
See:
  • Mixin.Events::emit()

ensureIndex() → {*}

Creates an index on the view.
Source:
See:
  • Collection::ensureIndex()
Returns:
Type
*

filter(query, func, optionsopt) → {Array}

Executes a method against each document that matches query and returns an array of documents that may have been modified by the method.
Parameters:
Name Type Attributes Description
query Object The query object.
func function The method that each document is passed to. If this method returns false for a particular document it is excluded from the results.
options Object <optional>
Optional options object.
Source:
Returns:
Type
Array

find() → {Array}

Queries the view data.
Source:
See:
  • Collection::find()
Returns:
The result of the find query.
Type
Array

findById() → {Array}

Queries the view data by specific id.
Source:
See:
  • Collection::findById()
Returns:
The result of the find query.
Type
Array

findOne() → {Object}

Queries the view data for a single document.
Source:
See:
  • Collection::findOne()
Returns:
The result of the find query.
Type
Object

findSub() → {Array}

Queries the view data in a sub-array.
Source:
See:
  • Collection::findSub()
Returns:
The result of the find query.
Type
Array

findSubOne() → {Object}

Queries the view data in a sub-array and returns first match.
Source:
See:
  • Collection::findSubOne()
Returns:
The result of the find query.
Type
Object

from(source, callbackopt) → {*}

Sets the source from which the view will assemble its data.
Parameters:
Name Type Attributes Description
source Collection | View The source to use to assemble view data.
callback function <optional>
A callback method.
Source:
Returns:
If no argument is passed, returns the current value of from, otherwise returns itself for chaining.
Type
*

ignoreTriggers()

Source:
See:
  • Mixin.Triggers::ignoreTriggers()

indexOf() → {*}

Source:
See:
  • Collection.indexOf
Returns:
Type
*

insert()

Executes an insert against the view's underlying data-source.
Source:
See:
  • Collection::insert()

off()

Cancels an event listener.
Source:
See:
  • Mixin.Events::off()

on()

/** Listens for an event.
Source:
See:
  • Mixin.Events::on()

orderBy(valopt) → {*}

Gets / sets the orderBy clause in the query options for the view.
Parameters:
Name Type Attributes Description
val Object <optional>
The order object.
Source:
Returns:
Type
*

page(valopt) → {*}

Gets / sets the page clause in the query options for the view.
Parameters:
Name Type Attributes Description
val Number <optional>
The page number to change to (zero index).
Source:
Returns:
Type
*

pageFirst() → {*}

Jump to the first page in the data set.
Source:
Returns:
Type
*

pageLast() → {*}

Jump to the last page in the data set.
Source:
Returns:
Type
*

pageScan(val) → {*}

Move forward or backwards in the data set pages by passing a positive or negative integer of the number of pages to move.
Parameters:
Name Type Description
val Number The number of pages to move.
Source:
Returns:
Type
*

primaryKey() → {String}

Gets the primary key for this view from the assigned collection.
Source:
See:
  • Collection::primaryKey()
Returns:
Type
String

processTrigger()

Source:
See:
  • Mixin.Triggers::processTrigger()

queryAdd(obj, overwrite, refreshopt)

Add data to the existing query.
Parameters:
Name Type Attributes Description
obj Object The data whose keys will be added to the existing query object.
overwrite Boolean Whether or not to overwrite data that already exists in the query object. Defaults to true.
refresh Boolean <optional>
Whether or not to refresh the view data set once the operation is complete. Defaults to true.
Source:

queryData(queryopt, optionsopt, refreshopt) → {*}

Gets / sets the query object and query options that the view uses to build it's data set. This call modifies both the query and query options at the same time.
Parameters:
Name Type Attributes Description
query Object <optional>
The query to set.
options Boolean <optional>
The query options object.
refresh Boolean <optional>
Whether to refresh the view data after this operation. Defaults to true.
Deprecated:
  • Use query(, , ) instead. Query now supports being presented with multiple different variations of arguments.
Source:
Returns:
Type
*

queryOptions(optionsopt, refreshopt) → {*}

Gets / sets the query options used when applying sorting etc to the view data set.
Parameters:
Name Type Attributes Description
options Object <optional>
An options object.
refresh Boolean <optional>
Whether to refresh the view data after this operation. Defaults to true.
Source:
Returns:
Type
*

queryRemove(obj, refreshopt)

Remove data from the existing query.
Parameters:
Name Type Attributes Description
obj Object The data whose keys will be removed from the existing query object.
refresh Boolean <optional>
Whether or not to refresh the view data set once the operation is complete. Defaults to true.
Source:

rebuildActiveBucket(orderByopt)

Clears the existing active bucket and builds a new one based on the passed orderBy object (if one is passed).
Parameters:
Name Type Attributes Description
orderBy Object <optional>
The orderBy object describing how to order any data.
Source:

refresh()

Refreshes the view data such as ordering etc.
Source:

remove()

Executes a remove against the view's underlying data-source.
Source:
See:
  • Collection::remove()

removeLinkIO()

Source:
See:
  • Mixin.Triggers::removeLinkIO()

removeTrigger()

Source:
See:
  • Mixin.Triggers::removeTrigger()

transform(obj) → {*}

Takes the passed data and uses it to set transform methods and globally enable or disable the transform system for the view.
Parameters:
Name Type Description
obj Object The new transform system settings "enabled", "dataIn" and "dataOut": { "enabled": true, "dataIn": function (data) { return data; }, "dataOut": function (data) { return data; } }
Source:
Returns:
Type
*

update()

Executes an update against the view's underlying data-source.
Source:
See:
  • Collection::update()

updateById()

Executes an updateById against the view's underlying data-source.
Source:
See:
  • Collection::updateById()

willTrigger()

Source:
See:
  • Mixin.Triggers::willTrigger()

Members

query

Gets / sets the query being used to generate the view data. It does not change or modify the view's query options.
Source: