Reference documentation and code samples for the Firestore in Datastore mode API class Google::Cloud::Datastore::GqlQuery.
GqlQuery
Represents a GQL query.
GQL is a SQL-like language for retrieving entities or keys from Datastore.
Inherits
- Object
Example
require "google/cloud/datastore" datastore = Google::Cloud::Datastore.new gql_query = Google::Cloud::Datastore::GqlQuery.new gql_query.query_string = "SELECT * FROM Task ORDER BY created ASC" tasks = datastore.run gql_query
Methods
#allow_literals
def allow_literals() -> Boolean
Whether the query may contain literal values. When false, the query string must not contain any literals and instead must bind all values using #named_bindings= or #positional_bindings=.
-
(Boolean) —
true
if the query may contain literal values
#allow_literals=
def allow_literals=(new_allow_literals)
Sets whether the query may contain literal values. When false, the query string must not contain any literals and instead must bind all values using #named_bindings= or #positional_bindings=.
-
new_allow_literals (Boolean) —
true
if the query may contain literal values
require "google/cloud/datastore" gql_query = Google::Cloud::Datastore::GqlQuery.new gql_query.query_string = "SELECT * FROM Task " \ "WHERE completed = false AND priority = 4" gql_query.allow_literals = true
#initialize
def initialize() -> GqlQuery
Returns a new GqlQuery instance.
- (GqlQuery) — a new instance of GqlQuery
require "google/cloud/datastore" gql_query = Google::Cloud::Datastore::GqlQuery.new
#named_bindings
def named_bindings() -> Hash
The named binding values for a query that contains named argument
binding sites that start with @
.
- (Hash) — a frozen hash that maps the binding site names in the query string to valid GQL arguments
#named_bindings=
def named_bindings=(new_named_bindings)
Sets named binding values for a query that contains named argument
binding sites that start with @
.
- new_named_bindings (Hash) — a hash that maps the binding site names in the query string to valid GQL arguments
require "google/cloud/datastore" gql_query = Google::Cloud::Datastore::GqlQuery.new gql_query.query_string = "SELECT * FROM Task " \ "WHERE done = @done " \ "AND priority = @priority" gql_query.named_bindings = {done: false, priority: 4}
#positional_bindings
def positional_bindings() -> Array
The binding values for a query that contains numbered argument binding
sites that start with @
.
- (Array) — a frozen array containing the query arguments in the order of the numbered binding sites in the query string
#positional_bindings=
def positional_bindings=(new_positional_bindings)
Sets the binding values for a query that contains numbered argument
binding sites that start with @
.
- new_positional_bindings (Array) — query arguments in the order of the numbered binding sites in the query string
require "google/cloud/datastore" gql_query = Google::Cloud::Datastore::GqlQuery.new gql_query.query_string = "SELECT * FROM Task" \ "WHERE completed = @1 AND priority = @2" gql_query.positional_bindings = [false, 4]
#query_string
def query_string() -> String
The GQL query string for the query. The string may contain named or
positional argument binding sites that start with @
. Corresponding
binding values should be set with #named_bindings= or
#positional_bindings=.
- (String) — a GQL statement
#query_string=
def query_string=(new_query_string)
Sets the GQL query string for the query. The string may contain named
or positional argument binding sites that start with @
.
Corresponding binding values should be set with #named_bindings= or
#positional_bindings=.
See the GQL Reference.
- new_query_string (String) — a valid GQL statement
gql_query = Google::Cloud::Datastore::GqlQuery.new gql_query.query_string = "SELECT * FROM Task " \ "WHERE done = @done " \ "AND priority = @priority" gql_query.named_bindings = {done: false, priority: 4}