# scan

### Spec

```typescript
async scan(
    tnmInput: TynamoScanInput<TSource> = {}
): Promise<TynamoScanOutput<TSource>>
```

### Input&#x20;

```typescript
export interface TynamoScanInput<TSource> {
    ExclusiveStartKey?: TSource;
    ExpressionAttributeValues?: any;

    // Derived from DynamoDB.
    IndexName?: IndexName;
    Limit?: PositiveIntegerObject;
    Select?: Select;
    ReturnConsumedCapacity?: ReturnConsumedCapacity;
    TotalSegments?: ScanTotalSegments;
    Segment?: ScanSegment;
    ProjectionExpression?: ProjectionExpression;
    FilterExpression?: ConditionExpression;
    ExpressionAttributeNames?: ExpressionAttributeNameMap;
    ConsistentRead?: ConsistentRead;
}
```

| Name                      | Type            | Info                                                                                                                                                   |
| ------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ExclusiveStartKey         | `@DynamoEntity` | The primary key of the first item that this operation will evaluate. Use the value that was returned for `LastEvaluatedKey` in the previous operation. |
| ExpressionAttributeValues | `@DynamoEntity` | Value used for expression.                                                                                                                             |

{% hint style="info" %}
Unlisted param is derived from `DynamoDB`.

Check [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html) for more information.
{% endhint %}

### Output

```typescript
export interface TynamoScanOutput<TSource> {
    Items?: TSource[];
    LastEvaluatedKey?: TSource;
    
    // Derived from DynamoDB.
    $response: AWS.Response<ScanOutput, AWS.AWSError>;
    Count?: Integer;
    ScannedCount?: Integer;
    ConsumedCapacity?: ConsumedCapacity;
}
```

| Name             | Type              | Info                          |
| ---------------- | ----------------- | ----------------------------- |
| Items            | `@DynamoEntity[]` | Result of `scan` operation.   |
| LastEvaluatedKey | `@DynamoEntity`   | Primary key of the last item. |

{% hint style="info" %}
Unlisted param is derived from `DynamoDB`.

Check [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html) for more information.
{% endhint %}

### Example

```typescript
@DynamoEntity()
class Cat {
    @DynamoProperty({ keyType: KeyType.hash })
    id!: number;

    @DynamoProperty({ keyType: KeyType.attr })
    name!: string;

    constructor(id: number, name: string) {
        this.id = id;
        this.name = name;
    }
}

const tynamo: Tynamo = new Tynamo({
    region: "ap-northeast-2",
    endpoint: "http://localhost:8000"
});
const tynamoTable = tynamo.getTableOf(Cat);


const step1 = await tynamoTable.scan();
const step2 = await tynamoTable.scan({ ExclusiveStartKey: step1.LastEvaluatedKey })
```
