@@ -78,6 +78,29 @@ case class Table[V: DynamoFormat](name: String) {
78
78
*/
79
79
def from [K : UniqueKeyCondition ](key : UniqueKey [K ]) = TableWithOptions (name, ScanamoQueryOptions .default).from(key)
80
80
81
+ /** Primes a search request with a key to start from:
82
+ * @param exclusiveStartKey
83
+ * A [[DynamoObject ]] containing attributes that match the partition key and sort key of the table
84
+ * @return
85
+ * A new [[Table ]] which when queried will return items after the provided exclusive start key
86
+ * @example
87
+ * {{{
88
+ * import org.scanamo._
89
+ * import org.scanamo.syntax._
90
+ *
91
+ * val table: Table[_] = ???
92
+ * val exclusiveStartKey = DynamoObject(
93
+ * Map(
94
+ * "myPartitionKeyName" -> myPartitionKeyValue.asDynamoValue,
95
+ * "mySortKeyName" -> mySortKeyValue.asDynamoValue
96
+ * )
97
+ * )
98
+ * val tableStartingFromExclusiveStartKey: Table[_] = table.from(exclusiveStartKey)
99
+ * }}}
100
+ */
101
+ def from (exclusiveStartKey : DynamoObject ) =
102
+ TableWithOptions (name, ScanamoQueryOptions .default).from(exclusiveStartKey)
103
+
81
104
/** Scans all elements of a table
82
105
*/
83
106
def scan (): ScanamoOps [List [Either [DynamoReadError , V ]]] = ScanamoFree .scan[V ](name)
@@ -170,6 +193,8 @@ private[scanamo] case class ConsistentlyReadTable[V: DynamoFormat](tableName: St
170
193
TableWithOptions (tableName, ScanamoQueryOptions .default).consistently.descending
171
194
def from [K : UniqueKeyCondition ](key : UniqueKey [K ]) =
172
195
TableWithOptions (tableName, ScanamoQueryOptions .default).consistently.from(key)
196
+ def from (exclusiveStartKey : DynamoObject ) =
197
+ TableWithOptions (tableName, ScanamoQueryOptions .default).consistently.from(exclusiveStartKey)
173
198
def filter [T ](c : Condition [T ]): TableWithOptions [V ] =
174
199
TableWithOptions (tableName, ScanamoQueryOptions .default).consistently.filter(c)
175
200
def scan (): ScanamoOps [List [Either [DynamoReadError , V ]]] =
@@ -199,6 +224,8 @@ private[scanamo] case class TableWithOptions[V: DynamoFormat](tableName: String,
199
224
def descending : TableWithOptions [V ] = copy(queryOptions = queryOptions.copy(ascending = false ))
200
225
def from [K : UniqueKeyCondition ](key : UniqueKey [K ]) =
201
226
copy(queryOptions = queryOptions.copy(exclusiveStartKey = Some (key.toDynamoObject)))
227
+ def from (exclusiveStartKey : DynamoObject ) =
228
+ copy(queryOptions = queryOptions.copy(exclusiveStartKey = Some (exclusiveStartKey)))
202
229
def filter [T ](c : Condition [T ]): TableWithOptions [V ] =
203
230
copy(queryOptions = queryOptions.copy(filter = Some (c)))
204
231
0 commit comments