[docs/tutorials,#113][s]: rework and extend section on records in basics tutorial and start section on filters in query tutorial.
This commit is contained in:
@@ -13,7 +13,7 @@ root: ../
|
||||
|
||||
## Preparations
|
||||
|
||||
See <a href="{{page.root}}/docs/tutorial-basics.html">first Dataset basics tutorial</a> for getting setup and initializing Dataset.
|
||||
See <a href="{{page.root}}/docs/tutorial-basics.html">first Dataset basics tutorial</a> for getting setup and initializing a Dataset.
|
||||
|
||||
<script type="text/javascript">
|
||||
{% include data.js %}
|
||||
@@ -24,13 +24,16 @@ var dataset = new recline.Model.Dataset({
|
||||
|
||||
## Querying
|
||||
|
||||
The basic thing we want to do with Datasets is query and filter them. This is very easy to do:
|
||||
The basic thing we want to do with Datasets is query and filter them. This is
|
||||
very easy to do:
|
||||
|
||||
{% highlight javascript %}
|
||||
{% include tutorial-basics-ex-2.js %}
|
||||
{% endhighlight %}
|
||||
|
||||
This results in the following. Note how recordCount is now 3 (the total number of records matched by the query) but that records only contains 2 records as we restricted number of returned records using the size attribute.
|
||||
This results in the following. Note how recordCount is now 3 (the total number
|
||||
of records matched by the query) but that records only contains 2 records as we
|
||||
restricted number of returned records using the size attribute.
|
||||
|
||||
<div class="ex-2 well"> </div>
|
||||
|
||||
@@ -39,8 +42,29 @@ $('.ex-2').html('');
|
||||
{% include tutorial-basics-ex-2.js %}
|
||||
</script>
|
||||
|
||||
Full details of the <a href="models.html#query">query structure and its options can be found in the reference documentation</a>.
|
||||
## Filtering
|
||||
|
||||
Also worth noting is that the last run query is stored as a <a href="models.html#query">Query instance</a> in the `queryState` attribute of the Dataset object. Modifying `queryState` will also resulting in a query being run. This is useful when building views that want to display or manage the query state (see, for example, <a href="src/widget.queryeditor.html">Query Editor</a> or <a href="src/widget.filtereditor.html">Filter Editor</a> widgets).
|
||||
A simple unstructured query like the one provided above searches all fieldsfor the value provided.
|
||||
|
||||
Often you want to "filter" results more precisely, for example by specifying a specific value in a specific field. To do this we use "filters".
|
||||
|
||||
{% highlight javascript %}
|
||||
var query = new recline.Model.Query();
|
||||
query.addFilter({type: 'term', field: 2});
|
||||
dataset.query(query);
|
||||
{% endhighlight %}
|
||||
|
||||
## QueryState
|
||||
|
||||
The last run query is stored as a <a href="models.html#query">Query
|
||||
instance</a> in the `queryState` attribute of the Dataset object. Modifying
|
||||
`queryState` will also resulting in a query being run. This is useful when
|
||||
building views that want to display or manage the query state (see, for
|
||||
example, <a href="src/widget.queryeditor.html">Query Editor</a> or <a
|
||||
href="src/widget.filtereditor.html">Filter Editor</a> widgets).
|
||||
|
||||
## Full Details of the Query Language
|
||||
|
||||
Full details of the <a href="models.html#query">query structure and its options
|
||||
can be found in the reference documentation</a>.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user