# Query

# Query


```
class Query
```

<br />

Known direct subclasses [DatabaseReference](https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/DatabaseReference)

|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/DatabaseReference` | A Firebase reference represents a particular location in your Database and can be used for reading or writing data to that Database location. |

*** ** * ** ***

The Query class (and its subclass, `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/DatabaseReference`) are used for reading data. Listeners are attached, and they will be triggered when the corresponding data changes. Instances of Query are obtained by calling startAt(), endAt(), or limit() on a DatabaseReference.

## Summary

| ### Public functions |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ChildEventListener` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#addChildEventListener(com.google.firebase.database.ChildEventListener)(listener: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ChildEventListener)` Add a listener for child events occurring at this location. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#addListenerForSingleValueEvent(com.google.firebase.database.ValueEventListener)(listener: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ValueEventListener)` Add a listener for a single change in the data at this location. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ValueEventListener` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#addValueEventListener(com.google.firebase.database.ValueEventListener)(listener: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ValueEventListener)` Add a listener for changes in the data at this location. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endAt(java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endAt(double)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endAt(boolean)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endAt(java.lang.String,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endAt(double,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endAt(boolean,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endBefore(java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endBefore(double)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)` Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endBefore(boolean)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endBefore(java.lang.String,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endBefore(double,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#endBefore(boolean,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#equalTo(java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with the given value. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#equalTo(double)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)` Creates a query constrained to only return child nodes with the given value. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#equalTo(boolean)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Creates a query constrained to only return child nodes with the given value. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#equalTo(java.lang.String,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return the child node with the given key and value. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#equalTo(double,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return the child node with the given key and value. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#equalTo(boolean,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return the child node with the given key and value. |
| `https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/DataSnapshot!>` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#get()()` Gets the server values for this query. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/DatabaseReference` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#getRef()()` |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#keepSynced(boolean)(keepSynced: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` By calling \`keepSynced(true)\` on a location, the data for that location will automatically be downloaded and kept in sync, even when no listeners are attached for that location. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#limitToFirst(int)(limit: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Creates a query with limit and anchor it to the start of the window. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#limitToLast(int)(limit: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Creates a query with limit and anchor it to the end of the window. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#orderByChild(java.lang.String)(path: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Creates a query in which child nodes are ordered by the values of the specified path. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#orderByKey()()` Creates a query in which child nodes are ordered by their keys. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#orderByPriority()()` Creates a query in which child nodes are ordered by their priorities. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#orderByValue()()` Creates a query in which nodes are ordered by their value |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#removeEventListener(com.google.firebase.database.ChildEventListener)(listener: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ChildEventListener)` Remove the specified listener from this location. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#removeEventListener(com.google.firebase.database.ValueEventListener)(listener: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ValueEventListener)` Remove the specified listener from this location. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAfter(java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAfter(double)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)` Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAfter(boolean)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAfter(java.lang.String,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value greater or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAfter(double,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAfter(boolean,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAt(java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAt(double)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAt(boolean)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAt(java.lang.String,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAt(double,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key. |
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#startAt(boolean,java.lang.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html, key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key. |

| ### Extension functions |
|---|---|
| `inline https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<T?>` | `<T : https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html> https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query.https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#(com.google.firebase.database.Query).values()()` Starts listening to this query and emits its values converted to a POJO via a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`. |

| ### Extension properties |
|---|---|
| `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ChildEvent>` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query.https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#(com.google.firebase.database.Query).childEvents()` Starts listening to this query's child events and emits its values via a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`. |
| `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/DataSnapshot>` | `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query.https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query#(com.google.firebase.database.Query).snapshots()` Starts listening to this query and emits its values via a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`. |

## Public functions

### addChildEventListener

```
fun addChildEventListener(listener: ChildEventListener): ChildEventListener
```

Add a listener for child events occurring at this location. When child locations are added, removed, changed, or moved, the listener will be triggered for the appropriate event

| Parameters |
|---|---|
| `listener: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ChildEventListener` | The listener to be called with changes |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ChildEventListener` | A reference to the listener provided. Save this to remove the listener later. |

### addListenerForSingleValueEvent

```
fun addListenerForSingleValueEvent(listener: ValueEventListener): Unit
```

Add a listener for a single change in the data at this location. This listener will be triggered once with the value of the data at the location.

| Parameters |
|---|---|
| `listener: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ValueEventListener` | The listener to be called with the data |

### addValueEventListener

```
fun addValueEventListener(listener: ValueEventListener): ValueEventListener
```

Add a listener for changes in the data at this location. Each time the data changes, your listener will be called with an immutable snapshot of the data.

| Parameters |
|---|---|
| `listener: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ValueEventListener` | The listener to be called with changes |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ValueEventListener` | A reference to the listener provided. Save this to remove the listener later. |

### endAt

```
fun endAt(value: String?): Query
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The value to end at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### endAt

```
fun endAt(value: Double): Query
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html` | The value to end at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### endAt

```
fun endAt(value: Boolean): Query
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default.

2.0

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | The value to end at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### endAt

```
fun endAt(value: String?, key: String?): Query
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The value to end at, inclusive |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key to end at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### endAt

```
fun endAt(value: Double, key: String?): Query
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html` | The value to end at, inclusive |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key to end at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### endAt

```
fun endAt(value: Boolean, key: String?): Query
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than or equal to the given key.

2.0

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | The value to end at, inclusive |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key to end at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
fun endBefore(value: String?): Query
```

Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The value to end at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
fun endBefore(value: Double): Query
```

Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html` | The value to end at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
fun endBefore(value: Boolean): Query
```

Creates a query constrained to only return child nodes with a value less than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | The value to end at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
fun endBefore(value: String?, key: String?): Query
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The value to end at |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key to end at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
fun endBefore(value: Double, key: String?): Query
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html` | The value to end at |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key to end at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### endBefore

```
fun endBefore(value: Boolean, key: String?): Query
```

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key less than the given key.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | The value to end at |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key to end at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
fun equalTo(value: String?): Query
```

Creates a query constrained to only return child nodes with the given value.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The value to query for |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
fun equalTo(value: Double): Query
```

Creates a query constrained to only return child nodes with the given value.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html` | The value to query for |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
fun equalTo(value: Boolean): Query
```

Creates a query constrained to only return child nodes with the given value.

2.0

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | The value to query for |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
fun equalTo(value: String?, key: String?): Query
```

Creates a query constrained to only return the child node with the given key and value. Note that there is at most one such child as names are unique.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The value to query for |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key of the child |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
fun equalTo(value: Double, key: String?): Query
```

Creates a query constrained to only return the child node with the given key and value. Note that there is at most one such child as keys are unique.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html` | The value to query for |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key of the child |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### equalTo

```
fun equalTo(value: Boolean, key: String?): Query
```

Creates a query constrained to only return the child node with the given key and value. Note that there is at most one such child as keys are unique.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | The value to query for |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The name of the child |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### get

```
fun get(): Task<DataSnapshot!>
```

Gets the server values for this query. Updates the cache and raises events if successful. If not connected, falls back to a locally-cached value.

### getRef

```
fun getRef(): DatabaseReference
```

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/DatabaseReference` | A DatabaseReference to this location |

### keepSynced

```
fun keepSynced(keepSynced: Boolean): Unit
```

By calling \`keepSynced(true)\` on a location, the data for that location will automatically be downloaded and kept in sync, even when no listeners are attached for that location. Additionally, while a location is kept synced, it will not be evicted from the persistent disk cache.

2.3

| Parameters |
|---|---|
| `keepSynced: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | Pass \`true\` to keep this location synchronized, pass \`false\` to stop synchronization. |

### limitToFirst

```
fun limitToFirst(limit: Int): Query
```

Creates a query with limit and anchor it to the start of the window.

2.0

| Parameters |
|---|---|
| `limit: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | The maximum number of child nodes to return |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### limitToLast

```
fun limitToLast(limit: Int): Query
```

Creates a query with limit and anchor it to the end of the window.

2.0

| Parameters |
|---|---|
| `limit: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | The maximum number of child nodes to return |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### orderByChild

```
fun orderByChild(path: String): Query
```

Creates a query in which child nodes are ordered by the values of the specified path.

2.0

| Parameters |
|---|---|
| `path: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | The path to the child node to use for sorting |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### orderByKey

```
fun orderByKey(): Query
```

Creates a query in which child nodes are ordered by their keys.

2.0

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### orderByPriority

```
fun orderByPriority(): Query
```

Creates a query in which child nodes are ordered by their priorities.

2.0

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### orderByValue

```
fun orderByValue(): Query
```

Creates a query in which nodes are ordered by their value

2.2

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### removeEventListener

```
fun removeEventListener(listener: ChildEventListener): Unit
```

Remove the specified listener from this location.

| Parameters |
|---|---|
| `listener: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ChildEventListener` | The listener to remove |

### removeEventListener

```
fun removeEventListener(listener: ValueEventListener): Unit
```

Remove the specified listener from this location.

| Parameters |
|---|---|
| `listener: https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ValueEventListener` | The listener to remove |

### startAfter

```
fun startAfter(value: String?): Query
```

Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The value to start at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### startAfter

```
fun startAfter(value: Double): Query
```

Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html` | The value to start at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### startAfter

```
fun startAfter(value: Boolean): Query
```

Creates a query constrained to only return child nodes with a value greater than the given value, using the given `orderBy` directive or priority as default.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | The value to start at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### startAfter

```
fun startAfter(value: String?, key: String?): Query
```

Creates a query constrained to only return child nodes with a value greater or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The value to start at |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key to start at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### startAfter

```
fun startAfter(value: Double, key: String?): Query
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html` | The value to start at |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key name to start at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### startAfter

```
fun startAfter(value: Boolean, key: String?): Query
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than the given key.

19.6

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | The value to start at |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key to start at, exclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
fun startAt(value: String?): Query
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The value to start at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
fun startAt(value: Double): Query
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html` | The value to start at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
fun startAt(value: Boolean): Query
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default.

2.0

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | The value to start at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
fun startAt(value: String?, key: String?): Query
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The priority to start at, inclusive |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key to start at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
fun startAt(value: Double, key: String?): Query
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html` | The priority to start at, inclusive |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key name to start at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

### startAt

```
fun startAt(value: Boolean, key: String?): Query
```

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given `orderBy` directive or priority as default, and additionally only child nodes with a key greater than or equal to the given key.

2.0

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | The priority to start at, inclusive |
| `key: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | The key to start at, inclusive |

| Returns |
|---|---|
| `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/Query` | A query with the new constraint |

## Extension functions

### values

```
inline fun <T : Any> Query.values(): Flow<T?>
```

Starts listening to this query and emits its values converted to a POJO via a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`.

- When the returned flow starts being collected, a `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ValueEventListener` will be attached.

- When the flow completes, the listener will be removed.

## Extension properties

### childEvents

```
val Query.childEvents: Flow<ChildEvent>
```

Starts listening to this query's child events and emits its values via a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`.

- When the returned flow starts being collected, a `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ChildEventListener` will be attached.

- When the flow completes, the listener will be removed.

### snapshots

```
val Query.snapshots: Flow<DataSnapshot>
```

Starts listening to this query and emits its values via a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`.

- When the returned flow starts being collected, a `https://firebase.google.com/docs/reference/kotlin/com/google/firebase/database/ValueEventListener` will be attached.

- When the flow completes, the listener will be removed.