Method: Contentstack::Query#exists?

Defined in:
lib/contentstack/query.rb

#exists?(field_uid) ⇒ Contentstack::Query

Add a constraint that requires, a specified key exists in response. Example:

@query = @stack.content_type('product').query
@query.exists?('product_image') # only fetch products which have a `product_image`

Parameters:

  • field_uid (String)

    The key to be constrained.

Returns:



105
106
107
# File 'lib/contentstack/query.rb', line 105

def exists?(field_uid)
  add_query_hash({:"#{field_uid}" => {"$exists" => true}})
end