Skip to content

Commit

Permalink
add index combinator
Browse files Browse the repository at this point in the history
  • Loading branch information
googley42 committed Oct 21, 2024
1 parent 59b265f commit 3b0b04a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ for {
stream <- queryAll[Equipment](tableName)
.whereKey(Equipment.id.partitionKey === "1" && Equipment.year.sortKey > 2020)
.execute
equipments <- stream.runCollect
} yield ()
```

## Combinators

```scala
<SCAN_ALL_QUERY>
.whereKey(<KeyConditionExpr>) // eg Equipment.id.partitionKey === "1" && Equipment.year.sortKey > 2020
.whereKey(<KeyConditionExpr>) // eg Equipment.id.partitionKey === "1" && Equipment.year.sortKey > 2020
.filter(<ConditionExpression>) // eg Equipment.price > 1.0 - filtering is done server side AFTER the scan
.index(<IndexName>) // use a secondary index
```
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ for {

```scala
<SCAN_SOME_QUERY>
.whereKey(<KeyConditionExpr>) // eg Equipment.id.partitionKey === "1" && Equipment.year.sortKey > 2020
.whereKey(<KeyConditionExpr>) // eg Equipment.id.partitionKey === "1" && Equipment.year.sortKey > 2020
.startKey(<LastEvaluatedKey>)
.filter(<ConditionExpression>) // eg Equipment.price > 1.0 - filtering is done server side AFTER the scan
.index(<IndexName>) // use a secondary index
```
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ for {
stream <- scanAll[Equipment](tableName)
.whereKey(Equipment.id.partitionKey === "1")
.execute
equipments <- stream.runCollect
equipments <- stream.tap(equip => ZIO.debug(s"equipment: $equip"))
} yield ()
```

Expand All @@ -29,5 +29,6 @@ for {
```scala
<SCAN_ALL_QUERY>
.filter(<ConditionExpression>) // eg Equipment.price > 1.0 - filtering is done server side AFTER the scan
.parallel(<N>) // executes a native DDB parallel scan on the server and merges the results back to the stream
.parallel(<N>) // executes a native DDB parallel scan on the server and merges the results back to the stream
.index(<IndexName>) // use a secondary index
```
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ for {
t <- scanSome[Equipment](tableName, limit = 2).execute
(page1, lastEvaluatedKey1) = t
t2 <- scanSome[Equipment](tableName, limit = 1).startKey(lastEvaluatedKey1).execute
equipments <- stream.runCollect
} yield ()
```

Expand All @@ -31,5 +30,6 @@ for {
```scala
<SCAN_SOME_QUERY>
.startKey(<LastEvaluatedKey>)
.filter(<ConditionExpression>) // eg Equipment.price > 1.0 - filtering is done server side AFTER the scan
.filter(<ConditionExpression>) // eg Equipment.price > 1.0 - filtering is done server side AFTER the scan
.index(<IndexName>) // use a secondary index
```

0 comments on commit 3b0b04a

Please sign in to comment.