Class: Google::Apis::FirestoreV1::StructuredQuery

Inherits:
Object
  • Object
show all
Includes:
Core::Hashable, Core::JsonObjectSupport
Defined in:
lib/google/apis/firestore_v1/classes.rb,
lib/google/apis/firestore_v1/representations.rb,
lib/google/apis/firestore_v1/representations.rb

Overview

A Firestore query. The query stages are executed in the following order: 1. from 2. where 3. select 4. order_by + start_at + end_at 5. offset 6. limit 7. find_nearest

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ StructuredQuery

Returns a new instance of StructuredQuery.



4542
4543
4544
# File 'lib/google/apis/firestore_v1/classes.rb', line 4542

def initialize(**args)
   update!(**args)
end

Instance Attribute Details

#end_atGoogle::Apis::FirestoreV1::Cursor

A position in a query result set. Corresponds to the JSON property endAt



4475
4476
4477
# File 'lib/google/apis/firestore_v1/classes.rb', line 4475

def end_at
  @end_at
end

#find_nearestGoogle::Apis::FirestoreV1::FindNearest

Nearest Neighbors search config. The ordering provided by FindNearest supersedes the order_by stage. If multiple documents have the same vector distance, the returned document order is not guaranteed to be stable between queries. Corresponds to the JSON property findNearest



4483
4484
4485
# File 'lib/google/apis/firestore_v1/classes.rb', line 4483

def find_nearest
  @find_nearest
end

#fromArray<Google::Apis::FirestoreV1::CollectionSelector>

The collections to query. Corresponds to the JSON property from



4488
4489
4490
# File 'lib/google/apis/firestore_v1/classes.rb', line 4488

def from
  @from
end

#limitFixnum

The maximum number of results to return. Applies after all other constraints. Requires: * The value must be greater than or equal to zero if specified. Corresponds to the JSON property limit

Returns:

  • (Fixnum)


4494
4495
4496
# File 'lib/google/apis/firestore_v1/classes.rb', line 4494

def limit
  @limit
end

#offsetFixnum

The number of documents to skip before returning the first result. This applies after the constraints specified by the WHERE, START AT, & END AT but before the LIMIT clause. Requires: * The value must be greater than or equal to zero if specified. Corresponds to the JSON property offset

Returns:

  • (Fixnum)


4502
4503
4504
# File 'lib/google/apis/firestore_v1/classes.rb', line 4502

def offset
  @offset
end

#order_byArray<Google::Apis::FirestoreV1::Order>

The order to apply to the query results. Callers can provide a full ordering, a partial ordering, or no ordering at all. While Firestore will always respect the provided order, the behavior for queries without a full ordering is different per database edition: In Standard edition, Firestore guarantees a stable ordering through the following rules: * The order_by is required to reference all fields used with an inequality filter. * All fields that are required to be in the order_by but are not already present are appended in lexicographical ordering of the field name. * If an order on __name__ is not specified, it is appended by default. Fields are appended with the same sort direction as the last order specified, or 'ASCENDING' if no order was specified. For example: * ORDER BY a becomes ORDER BY a ASC, __name__ ASC * ORDER BY a DESC becomes ORDER BY a DESC, __name__ DESC * WHERE a > 1 becomes WHERE a > 1 ORDER BY a ASC, __name__ ASC * WHERE __name__ > ... AND a > 1 becomes WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC In Enterprise edition, Firestore does not guarantee a stable ordering. Instead it will pick the most efficient ordering based on the indexes available at the time of query execution. This will result in a different ordering for queries that are otherwise identical. To ensure a stable ordering, always include a unique field in the order_by clause, such as __name__. Corresponds to the JSON property orderBy



4525
4526
4527
# File 'lib/google/apis/firestore_v1/classes.rb', line 4525

def order_by
  @order_by
end

#selectGoogle::Apis::FirestoreV1::Projection

The projection of document's fields to return. Corresponds to the JSON property select



4530
4531
4532
# File 'lib/google/apis/firestore_v1/classes.rb', line 4530

def select
  @select
end

#start_atGoogle::Apis::FirestoreV1::Cursor

A position in a query result set. Corresponds to the JSON property startAt



4535
4536
4537
# File 'lib/google/apis/firestore_v1/classes.rb', line 4535

def start_at
  @start_at
end

#whereGoogle::Apis::FirestoreV1::Filter

A filter. Corresponds to the JSON property where



4540
4541
4542
# File 'lib/google/apis/firestore_v1/classes.rb', line 4540

def where
  @where
end

Instance Method Details

#update!(**args) ⇒ Object

Update properties of this object



4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
# File 'lib/google/apis/firestore_v1/classes.rb', line 4547

def update!(**args)
  @end_at = args[:end_at] if args.key?(:end_at)
  @find_nearest = args[:find_nearest] if args.key?(:find_nearest)
  @from = args[:from] if args.key?(:from)
  @limit = args[:limit] if args.key?(:limit)
  @offset = args[:offset] if args.key?(:offset)
  @order_by = args[:order_by] if args.key?(:order_by)
  @select = args[:select] if args.key?(:select)
  @start_at = args[:start_at] if args.key?(:start_at)
  @where = args[:where] if args.key?(:where)
end