Method: WeaviateRecord::Queries::Where#where

Defined in:
lib/weaviate_record/queries/where.rb

#where(query = '', *values, **kw_args) ⇒ Object

Perform a where query on the collection. You can pass a string or keyword arguments as a query. It follows the same syntax as ActiveRecord where query. Chaining of where queries is also supported.

Example:

Article.where('title = ?', 'Hello World')
Article.where(title: 'Hello World')
Article.where('title = ? AND content = ?', 'Hello World', 'This is a content')
Article.where(title: 'Hello World').where(content: 'This is a content')


17
18
19
20
21
22
23
24
25
# File 'lib/weaviate_record/queries/where.rb', line 17

def where(query = '', *values, **kw_args)
  validate_arguments(query, values, kw_args)
  keyword_query = process_keyword_conditions(kw_args)
  string_query = process_string_conditions(query, *values)
  combined_query = combine_queries(keyword_query, string_query)
  @where_query = @where_query ? create_logical_condition(@where_query, 'And', combined_query) : combined_query
  @loaded = false
  self
end