Module: ink/probe

ink/probe

Queries objects in memory using a mongo-like notation for reaching into objects and filtering for records

Author:
  • Terry Weiss
License:
  • MIT
Source:

Namespaces

queryOperators
updateOperators

Members

<static> delimiter :string

The delimiter to use when splitting an expression

Type:
  • string
Default Value:
  • '.'
Source:

Methods

<static> all(obj, qu) → {boolean}

Returns true if all items match the query

Parameters:
Name Type Description
obj array | object

The object to query

qu object

The query to execute. See module:ink/probe.queryOperators for the operators you can use.

Source:
Returns:
Type
boolean

<static> any(obj, qu) → {boolean}

Returns true if any of the items match the query

Parameters:
Name Type Description
obj array | object

The object to query

qu object

The query to execute. See module:ink/probe.queryOperators for the operators you can use.

Source:
Returns:
Type
boolean

<static> bindTo(obj) → {object}

Binds the query and update methods to a specific object. When called these methods can skip the first parameter so that find(object, query) can just be called as find(query)

Parameters:
Name Type Description
obj object | array

The object or array to bind to

Source:
Returns:

An object with method bindings in place

Type
object

<static> every(obj, qu) → {boolean}

Returns true if all items match the query. Aliases as all

Parameters:
Name Type Description
obj array | object

The object to query

qu object

The query to execute

Source:
Returns:
Type
boolean

<static> find(obj, qu) → {array}

Find all records that match a query

Parameters:
Name Type Description
obj array | object

The object to query

qu object

The query to execute. See module:ink/probe.queryOperators for the operators you can use.

Source:
Returns:

The results

Type
array

<static> findKeys(obj, qu) → {array}

Find all records that match a query and returns the keys for those items. This is similar to module:ink/probe.find but instead of returning records, returns the keys. If obj is an object it will return the hash key. If 'obj' is an array, it will return the index

Parameters:
Name Type Description
obj array | object

The object to query

qu object

The query to execute. See module:ink/probe.queryOperators for the operators you can use.

Source:
Returns:
Type
array

<static> findOne(obj, qu) → {object}

Returns the first record that matches the query. Aliased as seek.

Parameters:
Name Type Description
obj array | object

The object to query

qu object

The query to execute. See module:ink/probe.queryOperators for the operators you can use.

Source:
Returns:
Type
object

<static> findOneKey(obj, qu) → {object}

Returns the first record that matches the query and returns its key or index depending on whether obj is an object or array respectively. Aliased as seekKey.

Parameters:
Name Type Description
obj array | object

The object to query

qu object

The query to execute. See module:ink/probe.queryOperators for the operators you can use.

Source:
Returns:
Type
object

<static> get(path, record) → {*}

Reaches into an object and allows you to get at a value deeply nested in an object. This is not a query, but a straight reach in, useful for event bindings

Parameters:
Name Type Description
path array

The split path of the element to work with

record object

The record to reach into

Source:
Returns:

Whatever was found in the record

Type
*

<static> mixTo(obj, collection)

Binds the query and update methods to a specific object and adds the methods to that object. When called these methods can skip the first parameter so that find(object, query) can just be called as object.find(query)

Parameters:
Name Type Description
obj object | array

The object or array to bind to

collection object | array

If the collection is not the same as <code>this</code> but is a property, or even a whole other object, you specify that here. Otherwise the <code>obj</code> is assumed to be the same as the collecion

Source:

<static> remove(obj, qu) → {object|array}

Remove all items in the object/array that match the query

Parameters:
Name Type Description
obj array | object

The object to query

qu object

The query to execute. See module:ink/probe.queryOperators for the operators you can use.

Source:
Returns:

The array or object as appropriate without the records.

Type
object | array

<static> set(path, record, setter, newValue)

This will write the value into a record at the path, creating intervening objects if they don't exist. This does not work as filtered update and is meant to be used on a single record. It is a nice way of setting a property at an arbitrary depth at will.

Parameters:
Name Type Description
path array

The split path of the element to work with

record object

The record to reach into

setter string

The set operation. See module:ink/probe.updateOperators for the operators you can use.

newValue object

The value to write to the, or if the operator is $pull, the query of items to look for

Source:

<static> some(obj, qu) → {boolean}

Returns true if any of the items match the query. Aliases as any

Parameters:
Name Type Description
obj array | object

The object to query

qu object

The query to execute

Source:
Returns:
Type
boolean

<static> unique(obj, qu) → {array}

Returns the set of unique records that match a query

Parameters:
Name Type Description
obj array | object

The object to query

qu object

The query to execute. See module:ink/probe.queryOperators for the operators you can use.

Source:
Returns:
Type
array

<static> update(obj, qu, setDocument)

Updates all records in obj that match the query. See module:ink/probe.updateOperators for the operators that are supported.

Parameters:
Name Type Description
obj object | array

The object to update

qu object

The query which will be used to identify the records to updated

setDocument object

The update operator. See module:ink/probe.updateOperators

Source:
ink-probe Copyright © 2012-2013 Terry Weiss. All rights reserved.
Documentation generated by JSDoc 3.2.0-dev on Sun Jun 09 2013 11:55:26 GMT-0400 (EDT) using the DocStrap template.