Descripción

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

Requires
Detalles

Terry Weiss

MIT

Clases


new queryOperators()


new updateOperators()

Miembros


<private, inner> nestedOps :array.<string>

Descripción

The list of operators that are nested within the expression object. These take the form {path:{operator:operand}}

Detalles
array.<string>

<private, inner> prefixOps :array.<string>

Descripción

The list of operators that prefix the expression object. These take the form {operator:{operands}} or {operator: [operands]}

Detalles
array.<string>

<static> delimiter :string

Descripción

The delimiter to use when splitting an expression

Detalles
string

'.'


<private, inner> operations

Descripción

The query operations that evaluate directly from an operation

Detalles

Métodos


<private, inner> processNestedOperator( path, operand ) → {object}

Descripción

Processes a nested operator by picking the operator out of the expression object. Returns a formatted object that can be used for querying

Parámetros
Nombre Tipo Descripción
path string

The path to element to work with

operand object

The operands to use for the query

Returns

A formatted operation definition

Detalles

<private, inner> processExpressionObject( val, key ) → {object}

Descripción

Interrogates a single query expression object and calls the appropriate handler for its contents

Parámetros
Nombre Tipo Descripción
val object

The expression

key object

The prefix

Returns

A formatted operation definition

Detalles

<private, inner> processPrefixOperator( operation, operand ) → {object}

Descripción

Processes a prefixed operator and then passes control to the nested operator method to pick out the contained values

Parámetros
Nombre Tipo Descripción
operation string

The operation prefix

operand object

The operands to use for the query

Returns

A formatted operation definition

Detalles

<private, inner> parseQueryExpression( obj ) → {object}

Descripción

Parses a query request and builds an object that can used to process a query target

Parámetros
Nombre Tipo Descripción
obj object

The expression object

Returns

All components of the expression in a kind of execution tree

Detalles

<private, inner> splitPath( path ) → {array}

Descripción

Splits a path expression into its component parts

Parámetros
Nombre Tipo Descripción
path string

The path to split

Returns
Detalles

<private, inner> reachin( path, record ) → {*}

Descripción

Reaches into an object and allows you to get at a value deeply nested in an object

Parámetros
Nombre Tipo Descripción
path array

The split path of the element to work with

record object

The record to reach into

Returns

Whatever was found in the record

Detalles

<private, inner> pushin( path, record, setter, newValue )

Descripción

This will write the value into a record at the path, creating intervening objects if they don't exist

Parámetros
Nombre Tipo Descripción
path array

The split path of the element to work with

record object

The record to reach into

setter string

The set command, defaults to $set

newValue object

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

Detalles

<private, inner> execQuery( obj, qu, shortCircuit, stopOnFirst )

Descripción

Executes a query by traversing a document and evaluating each record

Parámetros
Nombre Tipo Atributos Descripción
obj array | object

The object to query

qu object

The query to execute

shortCircuit boolean <nullable>

When true, the condition that matches the query stops evaluation for that record, otherwise all conditions have to be met

stopOnFirst boolean <nullable>

When true all evaluation stops after the first record is found to match the conditons

Detalles

<static> update( obj, qu, setDocument )

Descripción

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

Parámetros
Nombre Tipo Descripción
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:documents/probe.updateOperators

Detalles

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

Descripción

Find all records that match a query

Parámetros
Nombre Tipo Descripción
obj array | object

The object to query

qu object

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

Returns

The results

Detalles

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

Descripción

Find all records that match a query and returns the keys for those items. This is similar to module:documents/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

Parámetros
Nombre Tipo Descripción
obj array | object

The object to query

qu object

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

Returns
Detalles

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

Descripción

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

Parámetros
Nombre Tipo Descripción
obj array | object

The object to query

qu object

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

Returns
Detalles

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

Descripción

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.

Parámetros
Nombre Tipo Descripción
obj array | object

The object to query

qu object

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

Returns
Detalles

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

Descripción

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

Parámetros
Nombre Tipo Descripción
obj array | object

The object to query

qu object

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

Returns

The array or object as appropriate without the records.

Detalles

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

Descripción

Returns true if all items match the query

Parámetros
Nombre Tipo Descripción
obj array | object

The object to query

qu object

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

Returns
Detalles

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

Descripción

Returns true if any of the items match the query

Parámetros
Nombre Tipo Descripción
obj array | object

The object to query

qu object

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

Returns
Detalles

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

Descripción

Returns the set of unique records that match a query

Parámetros
Nombre Tipo Descripción
obj array | object

The object to query

qu object

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

Returns
Detalles

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

Descripción

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.

Parámetros
Nombre Tipo Descripción
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:documents/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

Detalles

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

Descripción

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

Parámetros
Nombre Tipo Descripción
path array

The split path of the element to work with

record object

The record to reach into

Returns

Whatever was found in the record

Detalles

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

Descripción

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

Parámetros
Nombre Tipo Descripción
obj array | object

The object to query

qu object

The query to execute

Returns
Detalles

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

Descripción

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

Parámetros
Nombre Tipo Descripción
obj array | object

The object to query

qu object

The query to execute

Returns
Detalles

<static> proxy( obj ) → {object}

Descripción

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

Parámetros
Nombre Tipo Descripción
obj object | array

The object or array to bind to

Returns

An object with method bindings in place

Detalles

<static> mixin( obj, collection )

Descripción

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)

Parámetros
Nombre Tipo Descripción
obj object | array

The object or array to bind to

collection object | array

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

Detalles