I can't figure out the correct syntax to perform a scan and filter on a table. I want to filter on books written after 2018.
Given this book model:
import { attribute, hashKey, rangeKey, table } from '@aws/dynamodb-data-mapper-annotations';
@table('book')
export class Book {
@hashKey()
isbn?: string;
@rangeKey()
written?: string; // an ISO-8601 string, e.g. 2020-05-30T16:34:20.985Z
@attribute()
title?: string;
}
My scan query filter:
mapper.scan(Book, { filter: '> 2018' }); // what goes here?
Unfortunantly, I get this TypeScript error:
Type 'string' is not assignable to type '(ConditionExpressionSubject & EqualityExpressionPredicate) | (ConditionExpressionSubject & InequalityExpressionPredicate) | ... 15 more ... | undefined'.
What is the correct filter syntax?