# Cloud Firestore API - Class Google::Cloud::Firestore::Filter (v3.2.0)

3.2.0 (latest) 3.1.1 3.0.0 2.16.1 2.15.1 2.14.0 2.13.1 2.12.0 2.11.0 2.10.1 2.9.1 2.8.0 2.7.2 2.6.6 Reference documentation and code samples for the Cloud Firestore API class Google::Cloud::Firestore::Filter.

Represents the filter for structured query.

## Inherits

- Object

## Methods

### #and

    def where(filter) -> Filter
    def where(field, operator, value) -> Filter

Joins filter using AND operator.


<br />

@param filter \[::Google::Cloud::Firestore::Filter\]
**Overloads**

    def where(filter) -> Filter

Pass Firestore::Filter to `where` via field_or_filter argument.

    def where(field, operator, value) -> Filter

Pass arguments to `where` via positional arguments. **Parameters**

- **field** ([FieldPath](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-FieldPath), String, Symbol) --- A field path to filter results with. If a [FieldPath](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-FieldPath "Google::Cloud::Firestore::FieldPath (class)") object is not provided then the field will be treated as a dotted string, meaning the string represents individual fields joined by ".". Fields containing `~`, `*`, `/`, `[`, `]`, and `.` cannot be in a dotted string, and should provided using a [FieldPath](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-FieldPath "Google::Cloud::Firestore::FieldPath (class)") object instead.
- **operator** (String, Symbol) ---

  The operation to compare the field
  to. Acceptable values include:
  - less than: `<`, `lt`
  - less than or equal: `<=`, `lte`
  - greater than: `>`, `gt`
  - greater than or equal: `>=`, `gte`
  - equal: `=`, `==`, `eq`, `eql`, `is`
  - not equal: `!=`
  - in: `in`
  - not in: `not-in`, `not_in`
  - array contains: `array-contains`, `array_contains`
- **value** (Object) ---

  The value to compare the property to. Defaults to nil.
  Possible values are:
  - Integer
  - Float/BigDecimal
  - String
  - Boolean
  - Array
  - Date/Time
  - StringIO
  - Google::Cloud::Datastore::Key
  - Google::Cloud::Datastore::Entity
  - nil
**Returns**

- ([Filter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-Filter)) --- New Filter object.
**Examples**

Pass a Filter type object in argument

```ruby
require "google/cloud/firestore"

filter_1 = Google::Cloud::Firestore.Firestore.new(:population, :>=, 1000000)
filter_2 = Google::Cloud::Firestore.Firestore.new("done", "=", "false")

filter = filter_1.and(filter_2)
```

Pass filter conditions in the argument

```ruby
require "google/cloud/firestore"

filter_1 = Google::Cloud::Firestore.Firestore.new(:population, :>=, 1000000)

filter = filter_1.and("done", "=", "false")
```

### #initialize

    def initialize(field, operator, value) -> Google::Cloud::Firestore::Filter

Create a Filter object.
**Parameters**

- **field** ([FieldPath](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-FieldPath), String, Symbol) --- A field path to filter results with. If a [FieldPath](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-FieldPath "Google::Cloud::Firestore::FieldPath (class)") object is not provided then the field will be treated as a dotted string, meaning the string represents individual fields joined by ".". Fields containing `~`, `*`, `/`, `[`, `]`, and `.` cannot be in a dotted string, and should provided using a [FieldPath](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-FieldPath "Google::Cloud::Firestore::FieldPath (class)") object instead.
- **operator** (String, Symbol) ---

  The operation to compare the field
  to. Acceptable values include:
  - less than: `<`, `lt`
  - less than or equal: `<=`, `lte`
  - greater than: `>`, `gt`
  - greater than or equal: `>=`, `gte`
  - equal: `=`, `==`, `eq`, `eql`, `is`
  - not equal: `!=`
  - in: `in`
  - not in: `not-in`, `not_in`
  - array contains: `array-contains`, `array_contains`
- **value** (Object) ---

  The value to compare the property to. Defaults to nil.
  Possible values are:
  - Integer
  - Float/BigDecimal
  - String
  - Boolean
  - Array
  - Date/Time
  - StringIO
  - Google::Cloud::Datastore::Key
  - Google::Cloud::Datastore::Entity
  - nil
**Returns**

- ([Google::Cloud::Firestore::Filter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-Filter)) --- New filter for the given condition
**Example**

```ruby
require "google/cloud/firestore"

firestore = Google::Cloud::Firestore.new

# Create a Filter
Google::Cloud::Firestore::Filter.new(:population, :>=, 1000000)
```

### #or

    def where(filter) -> Filter
    def where(field, operator, value) -> Filter

Joins filter using OR operator.


<br />

@param filter \[::Google::Cloud::Firestore::Filter\]
**Overloads**

    def where(filter) -> Filter

Pass Firestore::Filter to `where` via field_or_filter argument.

    def where(field, operator, value) -> Filter

Pass arguments to `where` via positional arguments. **Parameters**

- **field** ([FieldPath](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-FieldPath), String, Symbol) --- A field path to filter results with. If a [FieldPath](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-FieldPath "Google::Cloud::Firestore::FieldPath (class)") object is not provided then the field will be treated as a dotted string, meaning the string represents individual fields joined by ".". Fields containing `~`, `*`, `/`, `[`, `]`, and `.` cannot be in a dotted string, and should provided using a [FieldPath](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-FieldPath "Google::Cloud::Firestore::FieldPath (class)") object instead.
- **operator** (String, Symbol) ---

  The operation to compare the field
  to. Acceptable values include:
  - less than: `<`, `lt`
  - less than or equal: `<=`, `lte`
  - greater than: `>`, `gt`
  - greater than or equal: `>=`, `gte`
  - equal: `=`, `==`, `eq`, `eql`, `is`
  - not equal: `!=`
  - in: `in`
  - not in: `not-in`, `not_in`
  - array contains: `array-contains`, `array_contains`
- **value** (Object) ---

  The value to compare the property to. Defaults to nil.
  Possible values are:
  - Integer
  - Float/BigDecimal
  - String
  - Boolean
  - Array
  - Date/Time
  - StringIO
  - Google::Cloud::Datastore::Key
  - Google::Cloud::Datastore::Entity
  - nil
**Returns**

- ([Filter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/Google-Cloud-Firestore-Filter)) --- New Filter object.
**Examples**

Pass a Filter type object in argument

```ruby
require "google/cloud/firestore"

filter_1 = Google::Cloud::Firestore.Firestore.new(:population, :>=, 1000000)
filter_2 = Google::Cloud::Firestore.Firestore.new("done", "=", "false")

filter = filter_1.or(filter_2)
```

Pass filter conditions in the argument

```ruby
require "google/cloud/firestore"

filter_1 = Google::Cloud::Firestore.Firestore.new(:population, :>=, 1000000)

filter = filter_1.or("done", "=", "false")
```