# Class: documents/model

## documents/model

#### new documents/model()

  A model is the first level if usable data-bearing entity in the system. It does NOT include any verbs for saving or anything like that, it is a pure, in memory data container

  Source:
    - documents/model.js, line 34

### Members

#### isEmpty :boolean

  Returns true if this instance is empty

  ##### Type:

  - boolean
  Source:
    - documents/model.js, line 101

#### isNew :boolean

  If documents/model#_idField is filled in and it's value is empty this will be true.

  ##### Type:

  - boolean
  Source:
    - documents/model.js, line 86

### 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:documents/probe.queryOperators for the operators you can use.

  Source:
    - documents/probe.js, line 871

  ##### 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:documents/probe.queryOperators for the operators you can use.

  Source:
    - documents/probe.js, line 882

  ##### Returns:

  Type
    boolean

#### <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:
    - documents/probe.js, line 950

  ##### 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:documents/probe.queryOperators for the operators you can use.

  Source:
    - documents/probe.js, line 750

  ##### 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: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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `obj` | array | object | The object to query
  `qu` | object | The query to execute. See module:documents/probe.queryOperators for the operators you can use.

  Source:
    - documents/probe.js, line 769

  ##### 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:documents/probe.queryOperators for the operators you can use.

  Source:
    - documents/probe.js, line 788

  ##### 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:documents/probe.queryOperators for the operators you can use.

  Source:
    - documents/probe.js, line 813

  ##### 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:
    - documents/probe.js, line 930

  ##### Returns:

  Whatever was found in the record

  Type
    *

#### <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:documents/probe.queryOperators for the operators you can use.

  Source:
    - documents/probe.js, line 838

  ##### 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: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

  Source:
    - documents/probe.js, line 918

#### <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:
    - documents/probe.js, line 941

  ##### Returns:

  Type
    boolean

#### <static> update(obj, qu, setDocument)

  Updates all records in obj that match the query. See module:documents/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:documents/probe.updateOperators

  Source:
    - documents/probe.js, line 734