Packages

c

org.scanamo

SecondaryIndex

sealed abstract class SecondaryIndex[V] extends AnyRef

Represents a secondary index on a DynamoDB table.

Can be constructed via the index method on Table

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. SecondaryIndex
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def filter[C](condition: C)(implicit arg0: ConditionExpression[C]): SecondaryIndex[V]

    Filter the results of scan or query within DynamoDB

    Filter the results of scan or query within DynamoDB

    Note that rows filtered out still count towards your consumed capacity

    >>> case class Transport(mode: String, line: String, colour: String)
    
    >>> val client = LocalDynamoDB.client()
    >>> import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType._
    >>> import org.scanamo.syntax._
    >>> import org.scanamo.auto._
    
    >>> LocalDynamoDB.withRandomTableWithSecondaryIndex(client)(
    ...   'mode -> S, 'line -> S)('mode -> S, 'colour -> S
    ... ) { (t, i) =>
    ...   val transport = Table[Transport](t)
    ...   val operations = for {
    ...     _ <- transport.putAll(Set(
    ...       Transport("Underground", "Circle", "Yellow"),
    ...       Transport("Underground", "Metropolitan", "Magenta"),
    ...       Transport("Underground", "Central", "Red"),
    ...       Transport("Underground", "Picadilly", "Blue"),
    ...       Transport("Underground", "Northern", "Black")))
    ...     somethingBeginningWithC <- transport.index(i)
    ...                                   .filter('line beginsWith ("C"))
    ...                                   .query('mode -> "Underground")
    ...   } yield somethingBeginningWithC.toList
    ...   Scanamo.exec(client)(operations)
    ... }
    List(Right(Transport(Underground,Central,Red)), Right(Transport(Underground,Circle,Yellow)))
  2. abstract def from[K](key: UniqueKey[K])(implicit arg0: UniqueKeyCondition[K]): SecondaryIndex[V]
  3. abstract def limit(n: Int): SecondaryIndex[V]

    Query or scan an index, limiting the number of items evaluated by Dynamo

    Query or scan an index, limiting the number of items evaluated by Dynamo

    >>> case class Transport(mode: String, line: String, colour: String)
    
    >>> val client = LocalDynamoDB.client()
    >>> import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType._
    >>> import org.scanamo.syntax._
    >>> import org.scanamo.auto._
    
    >>> LocalDynamoDB.withRandomTableWithSecondaryIndex(client)(
    ...   'mode -> S, 'line -> S)('mode -> S, 'colour -> S
    ... ) { (t, i) =>
    ...   val transport = Table[Transport](t)
    ...   val operations = for {
    ...     _ <- transport.putAll(Set(
    ...       Transport("Underground", "Circle", "Yellow"),
    ...       Transport("Underground", "Metropolitan", "Magenta"),
    ...       Transport("Underground", "Central", "Red"),
    ...       Transport("Underground", "Picadilly", "Blue"),
    ...       Transport("Underground", "Northern", "Black")))
    ...     somethingBeginningWithBl <- transport.index(i).limit(1).query(
    ...       ('mode -> "Underground" and ('colour beginsWith "Bl")).descending
    ...     )
    ...   } yield somethingBeginningWithBl.toList
    ...   Scanamo.exec(client)(operations)
    ... }
    List(Right(Transport(Underground,Picadilly,Blue)))
  4. abstract def query(query: Query[_]): ScanamoOps[List[Either[DynamoReadError, V]]]

    Run a query against keys in a secondary index

    Run a query against keys in a secondary index

    >>> case class GithubProject(organisation: String, repository: String, language: String, license: String)
    
    >>> val client = LocalDynamoDB.client()
    >>> import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType._
    
    >>> import org.scanamo.syntax._
    >>> import org.scanamo.auto._
    
    >>> LocalDynamoDB.withRandomTableWithSecondaryIndex(client)('organisation -> S, 'repository -> S)('language -> S, 'license -> S) { (t, i) =>
    ...   val githubProjects = Table[GithubProject](t)
    ...   val operations = for {
    ...     _ <- githubProjects.putAll(Set(
    ...       GithubProject("typelevel", "cats", "Scala", "MIT"),
    ...       GithubProject("localytics", "sbt-dynamodb", "Scala", "MIT"),
    ...       GithubProject("tpolecat", "tut", "Scala", "MIT"),
    ...       GithubProject("guardian", "scanamo", "Scala", "Apache 2")
    ...     ))
    ...     scalaMIT <- githubProjects.index(i).query('language -> "Scala" and ('license -> "MIT"))
    ...   } yield scalaMIT.toList
    ...   Scanamo.exec(client)(operations)
    ... }
    List(Right(GithubProject(typelevel,cats,Scala,MIT)), Right(GithubProject(tpolecat,tut,Scala,MIT)), Right(GithubProject(localytics,sbt-dynamodb,Scala,MIT)))
  5. abstract def scan(): ScanamoOps[List[Either[DynamoReadError, V]]]

    Scan a secondary index

    Scan a secondary index

    This will only return items with a value present in the secondary index

    >>> case class Bear(name: String, favouriteFood: String, antagonist: Option[String])
    
    >>> val client = LocalDynamoDB.client()
    >>> import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType._
    
    >>> import org.scanamo.syntax._
    >>> import org.scanamo.auto._
    
    >>> LocalDynamoDB.withRandomTableWithSecondaryIndex(client)('name -> S)('antagonist -> S) { (t, i) =>
    ...   val table = Table[Bear](t)
    ...   val ops = for {
    ...     _ <- table.put(Bear("Pooh", "honey", None))
    ...     _ <- table.put(Bear("Yogi", "picnic baskets", Some("Ranger Smith")))
    ...     _ <- table.put(Bear("Paddington", "marmalade sandwiches", Some("Mr Curry")))
    ...     antagonisticBears <- table.index(i).scan()
    ...   } yield antagonisticBears
    ...   Scanamo.exec(client)(ops)
    ... }
    List(Right(Bear(Paddington,marmalade sandwiches,Some(Mr Curry))), Right(Bear(Yogi,picnic baskets,Some(Ranger Smith))))

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  16. def toString(): String
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped