<commit_before># 4. Querying lists

> Querying is a killer feature of AngularFire2. 
You can specify query values as observables, and when those
observables emit new values, the query is automatically re-run.

## Creating a query with primitive/scalar values

Queries are created by specifying a `query` object on the `FirebaseListObservable` options.

```ts
const queryObservable = af.database.list('/items', {
  query: {
    orderByChild: 'size',
    equalTo: 'large' 
  }
});
```

## Invalid query combinations

**Queries can only be ordered by one method.** This means you can only specify
`orderByChild`, `orderByKey`, `orderByPriority`, or `orderByValue`.

```ts
// WARNING: Do not copy and paste. This will not work!
const queryObservable = af.database.list('/items', {<commit_msg>docs(querying lists): added query options to the docs.<commit_after># 4. Querying lists

> Querying is a killer feature of AngularFire2. 
You can specify query values as observables, and when those
observables emit new values, the query is automatically re-run.

## Creating a query with primitive/scalar values

Queries are created by specifying a `query` object on the `FirebaseListObservable` options.

```ts
const queryObservable = af.database.list('/items', {
  query: {
    orderByChild: 'size',
    equalTo: 'large' 
  }
});
```

**Query Options:**
| method   | purpose            | 
| ---------|--------------------| 
| orderByChild | specify a child to order by |
| orderByKey | boolean to order by Firebase keys |
| orderByPriority | boolean to order by Firebase priority |
| orderByValue | specify a value to order by |
| equalTo | limit list to items that contain certain value |
| limitToFirst | limit response to x items starting at the beginning |
| limitToLast | limit response to x items starting at the end |
| startAt | key of item to start at |
| endAt | key of item to end at |
| shallow | boolean to only return item keys |

## Invalid query combinations

**Queries can only be ordered by one method.** This means you can only specify
`orderByChild`, `orderByKey`, `orderByPriority`, or `orderByValue`.

```ts
// WARNING: Do not copy and paste. This will not work!
const queryObservable = af.database.list('/items', {
{'fraction_non_alphanumeric': 0.10776829815895823, 'fraction_numerical': 0.001796138302649304, 'mean_word_length': 3.8967032967032966, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3915486', 'n_tokens_mistral': 631, 'n_tokens_neox': 609, 'n_words': 275}