Class: AWS::DynamoDB::ItemCollection::FilterBuilder

Inherits:
Object
  • Object
show all
Includes:
Types
Defined in:
lib/aws/dynamo_db/item_collection.rb

Overview

Provides a convenient syntax for expressing scan filters.

table.items.where(:path).begins_with("users/")

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Types

#format_attribute_value, #value_from_response, #values_from_response_hash

Constructor Details

#initialize(items, attribute) ⇒ FilterBuilder

Returns a new instance of FilterBuilder.



263
264
265
266
# File 'lib/aws/dynamo_db/item_collection.rb', line 263

def initialize(items, attribute)
  @items = items
  @attribute = attribute
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



260
261
262
# File 'lib/aws/dynamo_db/item_collection.rb', line 260

def attribute
  @attribute
end

#itemsObject (readonly)

Returns the value of attribute items.



258
259
260
# File 'lib/aws/dynamo_db/item_collection.rb', line 258

def items
  @items
end

Instance Method Details

#begins_with(value) ⇒ ItemCollection

Filters the collection to include only those items where this attribute begins with the argument.

Parameters:

  • value (String)

    The value to compare against.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



393
394
395
# File 'lib/aws/dynamo_db/item_collection.rb', line 393

def begins_with value
  @items.with_filter(attribute, "BEGINS_WITH", value)
end

#between(min, max) ⇒ ItemCollection

Filters the collection to include only those items where this attribute is between the two arguments.

Parameters:

  • min (String, Numeric)

    The minimum value.

  • max (String, Numeric)

    The maximum value.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



418
419
420
# File 'lib/aws/dynamo_db/item_collection.rb', line 418

def between min, max
  @items.with_filter(attribute, "BETWEEN", min, max)
end

#contains(value) ⇒ ItemCollection

Filters the collection to include only those items where this attribute contains the argument. If the attribute value is a set, this filter matches items where the argument is one of the values in the set. If the attribute value is a string, this filter matches items where the argument (which must be a string) is a substring of the attribute value.

Parameters:

  • value (String, Numeric)

    The value to compare against.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



366
367
368
# File 'lib/aws/dynamo_db/item_collection.rb', line 366

def contains value
  @items.with_filter(attribute, "CONTAINS", value)
end

#does_not_contain(value) ⇒ ItemCollection

Filters the collection to include only those items where this attribute does not contain the argument. If the attribute value is a set, this filter matches items where the argument is not present in the set. If the attribute value is a string, this filter matches items where the argument (which must be a string) is not a substring of the attribute value.

Parameters:

  • value (String, Numeric)

    The value to compare against.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



382
383
384
# File 'lib/aws/dynamo_db/item_collection.rb', line 382

def does_not_contain value
  @items.with_filter(attribute, "NOT_CONTAINS", value)
end

#equals(value) ⇒ ItemCollection

Filters the collection to include only those items where the value of this attribute is equal to the argument.

Parameters:

  • value (String, Numeric)

    The value to compare against.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



275
276
277
# File 'lib/aws/dynamo_db/item_collection.rb', line 275

def equals value
  @items.with_filter(attribute, "EQ", value)
end

#greater_than(value) ⇒ ItemCollection

Filters the collection to include only those items where the value of this attribute is greater than the argument.

Parameters:

  • value (String, Numeric)

    The value to compare against.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



308
309
310
# File 'lib/aws/dynamo_db/item_collection.rb', line 308

def greater_than value
  @items.with_filter(attribute, "GT", value)
end

#gte(value) ⇒ ItemCollection

Filters the collection to include only those items where the value of this attribute is greater than or equal to the argument.

Parameters:

  • value (String, Numeric)

    The value to compare against.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



332
333
334
# File 'lib/aws/dynamo_db/item_collection.rb', line 332

def gte value
  @items.with_filter(attribute, "GE", value)
end

#in(*values) ⇒ ItemCollection

Filters the collection to include only those items where this attribute equals one of the arguments.

Parameters:

  • values (Array<String, Numeric>)

    The values to compare against.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



405
406
407
# File 'lib/aws/dynamo_db/item_collection.rb', line 405

def in *values
  @items.with_filter(attribute, "IN", *values)
end

#is_nullItemCollection

Filters the collection to include only those items where this attribute does not exist.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



341
342
343
# File 'lib/aws/dynamo_db/item_collection.rb', line 341

def is_null
  @items.with_filter(attribute, "NULL")
end

#less_than(value) ⇒ ItemCollection

Filters the collection to include only those items where the value of this attribute is less than the argument.

Parameters:

  • value (String, Numeric)

    The value to compare against.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



297
298
299
# File 'lib/aws/dynamo_db/item_collection.rb', line 297

def less_than value
  @items.with_filter(attribute, "LT", value)
end

#lte(value) ⇒ ItemCollection

Filters the collection to include only those items where the value of this attribute is less than or equal to the argument.

Parameters:

  • value (String, Numeric)

    The value to compare against.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



320
321
322
# File 'lib/aws/dynamo_db/item_collection.rb', line 320

def lte value
  @items.with_filter(attribute, "LE", value)
end

#not_equal_to(value) ⇒ ItemCollection

Filters the collection to include only those items where the value of this attribute is not equal to the argument.

Parameters:

  • value (String, Numeric)

    The value to compare against.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



286
287
288
# File 'lib/aws/dynamo_db/item_collection.rb', line 286

def not_equal_to value
  @items.with_filter(attribute, "NE", value)
end

#not_nullItemCollection

Filters the collection to include only those items where this attribute exists.

Returns:

  • (ItemCollection)

    A new item collection filtered by this condition.



350
351
352
# File 'lib/aws/dynamo_db/item_collection.rb', line 350

def not_null
  @items.with_filter(attribute, "NOT_NULL")
end