Cloud Firestore API - Class Google::Cloud::Firestore::Filter (v2.12.0)

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.

@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, String, Symbol) — A field path to filter results with. If a FieldPath 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 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) — New Filter object.
Examples

Pass a Filter type object in argument

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

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, String, Symbol) — A field path to filter results with. If a FieldPath 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 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
Example
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.

@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, String, Symbol) — A field path to filter results with. If a FieldPath 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 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) — New Filter object.
Examples

Pass a Filter type object in argument

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

require "google/cloud/firestore"

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

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