Class

org.scanamo

SecondaryIndex

Related Doc: package scanamo

Permalink

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 descending: SecondaryIndex[V]

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

    Permalink

    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()
    >>> val scanamo = Scanamo(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(operations)
    ... }
    List(Right(Transport(Underground,Central,Red)), Right(Transport(Underground,Circle,Yellow)))
  3. abstract def from[K](key: UniqueKey[K])(implicit arg0: UniqueKeyCondition[K]): SecondaryIndex[V]

    Permalink
  4. abstract def limit(n: Int): SecondaryIndex[V]

    Permalink

    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()
    >>> val scanamo = Scanamo(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).descending.query(
    ...       ("mode" -> "Underground" and ("colour" beginsWith "Bl"))
    ...     )
    ...   } yield somethingBeginningWithBl.toList
    ...   scanamo.exec(operations)
    ... }
    List(Right(Transport(Underground,Picadilly,Blue)))
  5. abstract def query(query: Query[_]): ScanamoOps[List[Either[DynamoReadError, V]]]

    Permalink

    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()
    >>> val scanamo = Scanamo(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(operations)
    ... }
    List(Right(GithubProject(typelevel,cats,Scala,MIT)), Right(GithubProject(tpolecat,tut,Scala,MIT)), Right(GithubProject(localytics,sbt-dynamodb,Scala,MIT)))
  6. abstract def queryPaginatedM[M[_]](query: Query[_], pageSize: Int)(implicit arg0: Monad[M], arg1: MonoidK[M]): ScanamoOpsT[M, List[Either[DynamoReadError, V]]]

    Permalink

    Performs a scan with the ability to introduce effects into the computation.

    Performs a scan with the ability to introduce effects into the computation. This is useful for huge tables when you don't want to load the whole of it in memory, but scan it page by page, with a maximum of pageSize items per page.

    Note

    DynamoDB will only ever return maximum 1MB of data per query, so pageSize is an upper bound.

  7. abstract def scan(): ScanamoOps[List[Either[DynamoReadError, V]]]

    Permalink

    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()
    >>> val scanamo = Scanamo(client)
    >>> import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType._
    
    >>> 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(ops)
    ... }
    List(Right(Bear(Paddington,marmalade sandwiches,Some(Mr Curry))), Right(Bear(Yogi,picnic baskets,Some(Ranger Smith))))
  8. abstract def scanPaginatedM[M[_]](pageSize: Int)(implicit arg0: Monad[M], arg1: MonoidK[M]): ScanamoOpsT[M, List[Either[DynamoReadError, V]]]

    Permalink

    Performs a scan with the ability to introduce effects into the computation.

    Performs a scan with the ability to introduce effects into the computation. This is useful for huge tables when you don't want to load the whole of it in memory, but scan it page by page, with a maximum of pageSize items per page..

    Note

    DynamoDB will only ever return maximum 1MB of data per scan, so pageSize is an upper bound.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def queryM[M[_]](query: Query[_])(implicit arg0: Monad[M], arg1: MonoidK[M]): ScanamoOpsT[M, List[Either[DynamoReadError, V]]]

    Permalink

    Performs a query with the ability to introduce effects into the computation.

    Performs a query with the ability to introduce effects into the computation. This is useful for huge tables when you don't want to load the whole of it in memory, but scan it page by page.

    To control how many maximum items to load at once, use queryPaginatedM

  16. final def scanM[M[_]](implicit arg0: Monad[M], arg1: MonoidK[M]): ScanamoOpsT[M, List[Either[DynamoReadError, V]]]

    Permalink

    Performs a scan with the ability to introduce effects into the computation.

    Performs a scan with the ability to introduce effects into the computation. This is useful for huge tables when you don't want to load the whole of it in memory, but scan it page by page.

    To control how many maximum items to load at once, use scanPaginatedM

  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  18. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped